Compare commits

...

1 Commits

Author SHA1 Message Date
Oystein Kristoffer Tveit 4f92cda38a WIP 2024-10-19 21:13:07 +02:00
4 changed files with 197 additions and 94 deletions

View File

@ -7,11 +7,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1725242307, "lastModified": 1728687662,
"narHash": "sha256-a2iTMBngegEZvaNAzzxq5Gc5Vp3UWoGUqWtK11Txbic=", "narHash": "sha256-D9TChzb00eTG1YWBx8eN2s6lJJnBjB5Y7RpxkAzGvyQ=",
"owner": "nix-community", "owner": "nix-community",
"repo": "disko", "repo": "disko",
"rev": "96073e6423623d4a8027e9739d2af86d6422ea7a", "rev": "bdbdb725d632863bdedb80baabf21327614dd237",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -20,64 +20,25 @@
"type": "github" "type": "github"
} }
}, },
"fix-python": { "greg": {
"inputs": { "inputs": {
"flake-utils": "flake-utils",
"nixpkgs": [
"grzegorz",
"nixpkgs"
]
},
"locked": {
"lastModified": 1725463969,
"narHash": "sha256-d3c1TAlIN1PtK+oQP1wO6XbDfmR4SUp/C/4s7G46ARo=",
"owner": "GuillaumeDesforges",
"repo": "fix-python",
"rev": "2926402234c3f99aa8e4608c51d9ffa73ea403c0",
"type": "github"
},
"original": {
"owner": "GuillaumeDesforges",
"repo": "fix-python",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1689068808,
"narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4",
"type": "github"
},
"original": {
"id": "flake-utils",
"type": "indirect"
}
},
"grzegorz": {
"inputs": {
"fix-python": "fix-python",
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs"
] ],
"rust-overlay": "rust-overlay"
}, },
"locked": { "locked": {
"lastModified": 1726861911, "lastModified": 1722796402,
"narHash": "sha256-pXPmVp4AgszzJXlLjj8r9NxoDvxoV4USGaiMwqCyb4M=", "narHash": "sha256-Y6PdbTcfzDAZkVTLhTbRJMJCVR3KtCI7QyGqPR141uw=",
"ref": "refs/heads/master", "ref": "refs/heads/main",
"rev": "d10db19d7df5c5c2cd2dcb878376d5d681f6c2f2", "rev": "c1438f248020e4c71673c59501ae87ea4f5bec4f",
"revCount": 94, "revCount": 16,
"type": "git", "type": "git",
"url": "https://git.pvv.ntnu.no/Projects/grzegorz.git" "url": "https://git.pvv.ntnu.no/Projects/greg-ng.git"
}, },
"original": { "original": {
"type": "git", "type": "git",
"url": "https://git.pvv.ntnu.no/Projects/grzegorz.git" "url": "https://git.pvv.ntnu.no/Projects/greg-ng.git"
} }
}, },
"grzegorz-clients": { "grzegorz-clients": {
@ -158,11 +119,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1725198597, "lastModified": 1728692301,
"narHash": "sha256-w3sjCEbnc242ByJ18uebzgjFZY3QU7dZhmLwPsJIZJs=", "narHash": "sha256-QuWjkLVCuWWTyIUOSc4NRoZMNiLaWKV4jM4Vkhz0gfo=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "3524b030c839db4ea4ba16737789c6fb8a1769c6", "rev": "ee4d0513c7e6c4dedc8e9865d525cc86b1c3af8a",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -174,11 +135,11 @@
}, },
"nixpkgs-stable": { "nixpkgs-stable": {
"locked": { "locked": {
"lastModified": 1721524707, "lastModified": 1728156290,
"narHash": "sha256-5NctRsoE54N86nWd0psae70YSLfrOek3Kv1e8KoXe/0=", "narHash": "sha256-uogSvuAp+1BYtdu6UWuObjHqSbBohpyARXDWqgI12Ss=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "556533a23879fc7e5f98dd2e0b31a6911a213171", "rev": "17ae88b569bb15590549ff478bab6494dde4a907",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -190,11 +151,11 @@
}, },
"nixpkgs-unstable": { "nixpkgs-unstable": {
"locked": { "locked": {
"lastModified": 1725183711, "lastModified": 1728709450,
"narHash": "sha256-gkjg8FfjL92azt3gzZUm1+v+U4y+wbQE630uIf4Aybo=", "narHash": "sha256-QToJSkKLD7g9g2lSbqJ7D01uUv7Iv0+ToTUNQMU+r1o=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "a2c345850e5e1d96c62e7fa8ca6c9d77ebad1c37", "rev": "162ee4189cf5c0449a642f3f5aa7566faac77476",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -247,7 +208,7 @@
"root": { "root": {
"inputs": { "inputs": {
"disko": "disko", "disko": "disko",
"grzegorz": "grzegorz", "greg": "greg",
"grzegorz-clients": "grzegorz-clients", "grzegorz-clients": "grzegorz-clients",
"matrix-next": "matrix-next", "matrix-next": "matrix-next",
"minecraft-data": "minecraft-data", "minecraft-data": "minecraft-data",
@ -259,6 +220,27 @@
"sops-nix": "sops-nix" "sops-nix": "sops-nix"
} }
}, },
"rust-overlay": {
"inputs": {
"nixpkgs": [
"greg",
"nixpkgs"
]
},
"locked": {
"lastModified": 1722651535,
"narHash": "sha256-2uRmNwxe3CO5h7PfvqXrRe8OplXaEdwhqOUtaF13rpU=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "56d83ca6f3c557647476f3720426a7615c22b860",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
},
"sops-nix": { "sops-nix": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -267,11 +249,11 @@
"nixpkgs-stable": "nixpkgs-stable" "nixpkgs-stable": "nixpkgs-stable"
}, },
"locked": { "locked": {
"lastModified": 1725201042, "lastModified": 1728345710,
"narHash": "sha256-lj5pxOwidP0W//E7IvyhbhXrnEUW99I07+QpERnzTS4=", "narHash": "sha256-lpunY1+bf90ts+sA2/FgxVNIegPDKCpEoWwOPu4ITTQ=",
"owner": "Mic92", "owner": "Mic92",
"repo": "sops-nix", "repo": "sops-nix",
"rev": "5db5921e40ae382d6716dce591ea23b0a39d96f7", "rev": "06535d0e3d0201e6a8080dd32dbfde339b94f01b",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -279,21 +261,6 @@
"repo": "sops-nix", "repo": "sops-nix",
"type": "github" "type": "github"
} }
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

View File

@ -23,8 +23,10 @@
nix-gitea-themes.url = "git+https://git.pvv.ntnu.no/oysteikt/nix-gitea-themes.git"; nix-gitea-themes.url = "git+https://git.pvv.ntnu.no/oysteikt/nix-gitea-themes.git";
nix-gitea-themes.inputs.nixpkgs.follows = "nixpkgs"; nix-gitea-themes.inputs.nixpkgs.follows = "nixpkgs";
grzegorz.url = "git+https://git.pvv.ntnu.no/Projects/grzegorz.git"; greg.url = "git+https://git.pvv.ntnu.no/Projects/greg-ng.git";
grzegorz.inputs.nixpkgs.follows = "nixpkgs"; greg.inputs.nixpkgs.follows = "nixpkgs";
# grzegorz.url = "git+https://git.pvv.ntnu.no/Projects/grzegorz.git";
# grzegorz.inputs.nixpkgs.follows = "nixpkgs";
grzegorz-clients.url = "git+https://git.pvv.ntnu.no/Projects/grzegorz-clients.git"; grzegorz-clients.url = "git+https://git.pvv.ntnu.no/Projects/grzegorz-clients.git";
grzegorz-clients.inputs.nixpkgs.follows = "nixpkgs"; grzegorz-clients.inputs.nixpkgs.follows = "nixpkgs";
@ -116,15 +118,21 @@
brzeczyszczykiewicz = stableNixosConfig "brzeczyszczykiewicz" { brzeczyszczykiewicz = stableNixosConfig "brzeczyszczykiewicz" {
modules = [ modules = [
inputs.grzegorz.nixosModules.grzegorz-kiosk # inputs.greg.nixosModules.default
inputs.grzegorz-clients.nixosModules.grzegorz-webui inputs.grzegorz-clients.nixosModules.grzegorz-webui
]; ];
overlays = [
inputs.greg.overlays.default
];
}; };
georg = stableNixosConfig "georg" { georg = stableNixosConfig "georg" {
modules = [ modules = [
inputs.grzegorz.nixosModules.grzegorz-kiosk # inputs.greg.nixosModules.default
inputs.grzegorz-clients.nixosModules.grzegorz-webui inputs.grzegorz-clients.nixosModules.grzegorz-webui
]; ];
overlays = [
inputs.greg.overlays.default
];
}; };
}; };

101
modules/greg.nix Normal file
View File

@ -0,0 +1,101 @@
{ config, pkgs, lib, ... }:
let
cfg = config.services.greg-ng;
in
{
options.services.greg-ng = {
enable = lib.mkEnableOption "greg-ng, an mpv based media player";
package = lib.mkPackageOption pkgs "greg-ng" { };
mpvPackage = lib.mkPackageOption pkgs "mpv" { };
# TODO: create some better descriptions
settings = {
host = lib.mkOption {
type = lib.types.str;
default = "localhost";
example = "0.0.0.0";
description = ''
Which host to bind to.
'';
};
port = lib.mkOption {
type = lib.types.port;
default = 8008;
example = 10008;
description = ''
Which port to bind to.
'';
};
mpv-socket-path = lib.mkOption {
type = lib.types.str;
default = "%t/greg-ng-mpv.sock";
description = ''
Path to the mpv socket.
'';
};
mpv-executable-path = lib.mkOption {
type = lib.types.str;
default = lib.getExe cfg.mpvPackage;
defaultText = lib.literalExpression ''
lib.getExe config.services.greg-ng.mpvPackage
'';
description = ''
Path to the mpv executable.
'';
};
mpv-config-file = lib.mkOption {
type = with lib.types; nullOr str;
default = null;
description = ''
Path to the mpv config file.
'';
};
auto-start-mpv = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Whether to automatically start mpv.
'';
};
force-auto-start = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Whether to force auto starting mpv.
'';
};
};
};
config = {
users.users."greg".isNormalUser = true;
# services.cage.user = "greg";
# services.cage.enable = true;
# services.cage.program =let
# flags = lib.cli.toGNUCommandLineShell { } cfg.settings;
# in pkgs.writeShellScript "greg-kiosk" ''
# cd $(mktemp -d)
# ${lib.getExe cfg.package} ${flags}
# '';
# services.cage.user = "greg";
# users.users."greg".isNormalUser = true;
# system.activationScripts = {
# base-dirs = {
# text = ''
# mkdir -p /nix/var/nix/profiles/per-user/greg
# '';
# deps = [];
# };
# };
};
}

View File

@ -1,8 +1,10 @@
{config, lib, pkgs, ...}: {config, lib, pkgs, ...}:
let let
grg = config.services.grzegorz; grg = config.services.greg-ng;
grgw = config.services.grzegorz-webui; grgw = config.services.grzegorz-webui;
in { in {
imports = [ ./greg.nix ];
services.pipewire.enable = true; services.pipewire.enable = true;
services.pipewire.alsa.enable = true; services.pipewire.alsa.enable = true;
services.pipewire.alsa.support32Bit = true; services.pipewire.alsa.support32Bit = true;
@ -13,19 +15,44 @@ in {
description = "pvv"; description = "pvv";
}; };
services.grzegorz.enable = true; # services.grzegorz.enable = true;
services.grzegorz.listenAddr = "localhost"; # services.grzegorz.listenAddr = "localhost";
services.grzegorz.listenPort = 31337; # services.grzegorz.listenPort = 31337;
services.greg-ng.enable = true;
services.greg-ng.settings.host = "localhost";
services.greg-ng.settings.port = 31337;
services.grzegorz-webui.enable = true; services.grzegorz-webui.enable = true;
services.grzegorz-webui.listenAddr = "localhost"; services.grzegorz-webui.listenAddr = "localhost";
services.grzegorz-webui.listenPort = 42069; services.grzegorz-webui.listenPort = 42069;
services.grzegorz-webui.listenWebsocketPort = 42042; services.grzegorz-webui.listenWebsocketPort = 42042;
services.grzegorz-webui.hostName = "${config.networking.fqdn}"; services.grzegorz-webui.hostName = "${config.networking.fqdn}";
services.grzegorz-webui.apiBase = "http://${toString grg.listenAddr}:${toString grg.listenPort}/api"; services.grzegorz-webui.apiBase = "http://${grg.settings.host}:${toString grg.settings.port}/api";
xdg.portal = {
enable = true;
wlr.enable = true;
extraPortals = [ pkgs.xdg-desktop-portal-gtk ];
};
services.greetd = {
enable = true;
settings = rec {
initial_session = {
command = "${pkgs.sway}/bin/sway";
user = "pvv";
};
default_session = initial_session;
};
};
programs.sway = {
enable = true;
wrapperFeatures.gtk = true;
};
services.nginx.enable = true; services.nginx.enable = true;
services.nginx.virtualHosts."${config.networking.fqdn}" = { services.nginx.virtualHosts."${config.networking.fqdn}" = {
forceSSL = true; forceSSL = true;
enableACME = true; enableACME = true;
@ -40,18 +67,18 @@ in {
''; '';
locations."/" = { locations."/" = {
proxyPass = "http://localhost:${builtins.toString config.services.grzegorz-webui.listenPort}"; proxyPass = "http://${grgw.listenAddr}:${toString grgw.listenPort}";
}; };
# https://github.com/rawpython/remi/issues/216 # https://github.com/rawpython/remi/issues/216
locations."/websocket" = { locations."/websocket" = {
proxyPass = "http://localhost:${builtins.toString config.services.grzegorz-webui.listenWebsocketPort}"; proxyPass = "http://${grgw.listenAddr}:${toString grgw.listenWebsocketPort}";
proxyWebsockets = true; proxyWebsockets = true;
}; };
locations."/api" = { locations."/api" = {
proxyPass = "http://localhost:${builtins.toString config.services.grzegorz.listenPort}"; proxyPass = "http://${grg.settings.host}:${toString grg.settings.port}";
}; };
locations."/docs" = { locations."/docs" = {
proxyPass = "http://localhost:${builtins.toString config.services.grzegorz.listenPort}"; proxyPass = "http://${grg.settings.host}:${toString grg.settings.port}";
}; };
}; };