From 066a33587debe4a4c8e9465882d39cb3160e7142 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Sat, 16 Dec 2023 20:24:38 +0000 Subject: [PATCH 01/33] home: mpv: add uosc script --- modules/home/mpv/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/home/mpv/default.nix b/modules/home/mpv/default.nix index 9aef379..931c252 100644 --- a/modules/home/mpv/default.nix +++ b/modules/home/mpv/default.nix @@ -13,6 +13,7 @@ in scripts = [ pkgs.mpvScripts.mpris # Allow controlling using media keys + pkgs.mpvScripts.uosc # Nicer UI ]; }; }; From a657a7742eec560caaca8d4925b83671490cb548 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Mon, 18 Dec 2023 09:41:35 +0000 Subject: [PATCH 02/33] home: wm: i3bar: fix 'net' block when disconnected I still sometimes get the error message about not being able to format the block, this should fix it. --- modules/home/wm/i3bar/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/home/wm/i3bar/default.nix b/modules/home/wm/i3bar/default.nix index 5dbb505..5ae0e7d 100644 --- a/modules/home/wm/i3bar/default.nix +++ b/modules/home/wm/i3bar/default.nix @@ -74,7 +74,7 @@ in ) { block = "net"; - format = " $icon{| $ssid|} $ip{| $signal_strength|} "; + format = " $icon{| $ssid|}{| $ip|}{| $signal_strength|} "; } { block = "backlight"; From 13d85c30f98eacbc512fcf27bb76ede4dd30f7ef Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Tue, 19 Dec 2023 19:08:10 +0100 Subject: [PATCH 03/33] pkgs: remove 'wifi-qr' Now that I added it to upstream, I can get rid of it. --- pkgs/default.nix | 2 - pkgs/wifi-qr/default.nix | 81 ---------------------------------------- 2 files changed, 83 deletions(-) delete mode 100644 pkgs/wifi-qr/default.nix diff --git a/pkgs/default.nix b/pkgs/default.nix index 3a8e812..6b7fce1 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -28,7 +28,5 @@ pkgs.lib.makeScope pkgs.newScope (pkgs: { unbound-zones-adblock = pkgs.callPackage ./unbound-zones-adblock { }; - wifi-qr = pkgs.callPackage ./wifi-qr { }; - zsh-done = pkgs.callPackage ./zsh-done { }; }) diff --git a/pkgs/wifi-qr/default.nix b/pkgs/wifi-qr/default.nix deleted file mode 100644 index 88164e5..0000000 --- a/pkgs/wifi-qr/default.nix +++ /dev/null @@ -1,81 +0,0 @@ -{ lib -, fetchFromGitHub -, gnome -, installShellFiles -, makeWrapper -, networkmanager -, qrencode -, stdenvNoCC -, xdg-utils -, zbar -}: -stdenvNoCC.mkDerivation rec { - pname = "wifi-qr"; - version = "unstable-2023-04-19"; - - outputs = [ "out" "man" ]; - - src = fetchFromGitHub { - owner = "kokoye2007"; - repo = "wifi-qr"; - rev = "b81d4a44257252f07e745464879aa5618ae3d434"; - hash = "sha256-oGTAr+raJGpK4PV4GdBxX8fIUE8gcbXw7W0SvQJAee0="; - }; - - nativeBuildInputs = [ - installShellFiles - makeWrapper - ]; - - dontBuild = true; - - dontConfigure = true; - - postPatch = '' - substituteInPlace wifi-qr.desktop \ - --replace "Exec=sh -c 'wifi-qr g'" "Exec=$out/bin/wifi-qr g" \ - --replace "Exec=sh -c 'wifi-qr q'" "Exec=$out/bin/wifi-qr q" \ - --replace "Exec=sh -c 'wifi-qr p'" "Exec=$out/bin/wifi-qr p" \ - --replace "Exec=sh -c 'wifi-qr c'" "Exec=$out/bin/wifi-qr c" \ - --replace "Icon=wifi-qr.svg" "Icon=wifi-qr" - ''; - - installPhase = '' - runHook preInstall - - install -Dm755 wifi-qr $out/bin/wifi-qr - - install -Dm644 wifi-qr.desktop $out/share/applications/wifi-qr.desktop - install -Dm644 wifi-qr.svg $out/share/icons/hicolor/scalable/apps/wifi-qr.svg - - installManPage wifi-qr.1 - - runHook postInstall - ''; - - wrapperPath = lib.makeBinPath [ - gnome.zenity - networkmanager - qrencode - xdg-utils - zbar - ]; - - fixupPhase = '' - runHook preFixup - - patchShebangs $out/bin/wifi-qr - wrapProgram $out/bin/wifi-qr --suffix PATH : "${wrapperPath}" - - runHook postFixup - ''; - - meta = with lib; { - description = "WiFi password sharing via QR codes"; - homepage = "https://github.com/kokoye2007/wifi-qr"; - license = with licenses; [ gpl3Plus ]; - mainProgram = "wifi-qr"; - maintainers = with maintainers; [ ambroisie ]; - platforms = platforms.linux; - }; -} From 26950332c7176f98e3a35273d6e8bdd7118a1352 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Tue, 19 Dec 2023 22:00:32 +0100 Subject: [PATCH 04/33] home: keyboard: extract from X module This deserves to be its own standalone module, as I would want to use it in both X and Wayland, etc... --- modules/home/default.nix | 1 + modules/home/{x => }/keyboard/default.nix | 6 +++++- modules/home/x/default.nix | 4 ---- 3 files changed, 6 insertions(+), 5 deletions(-) rename modules/home/{x => }/keyboard/default.nix (50%) diff --git a/modules/home/default.nix b/modules/home/default.nix index 8ba3a8d..4dcfc35 100644 --- a/modules/home/default.nix +++ b/modules/home/default.nix @@ -23,6 +23,7 @@ ./gtk ./htop ./jq + ./keyboard ./mail ./mpv ./nix diff --git a/modules/home/x/keyboard/default.nix b/modules/home/keyboard/default.nix similarity index 50% rename from modules/home/x/keyboard/default.nix rename to modules/home/keyboard/default.nix index 40af800..2216a08 100644 --- a/modules/home/x/keyboard/default.nix +++ b/modules/home/keyboard/default.nix @@ -1,8 +1,12 @@ { config, lib, ... }: let - cfg = config.my.home.x; + cfg = config.my.home.keyboard; in { + options.my.home.keyboard = with lib; { + enable = my.mkDisableOption "keyboard configuration"; + }; + config = lib.mkIf cfg.enable { home.keyboard = { layout = "fr"; diff --git a/modules/home/x/default.nix b/modules/home/x/default.nix index 0312bc4..c320e52 100644 --- a/modules/home/x/default.nix +++ b/modules/home/x/default.nix @@ -3,10 +3,6 @@ let cfg = config.my.home.x; in { - imports = [ - ./keyboard - ]; - options.my.home.x = with lib; { enable = mkEnableOption "X server configuration"; }; From faa87743e5f54be48874282aa4d244a1482e6e72 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Mon, 25 Dec 2023 19:25:08 +0100 Subject: [PATCH 05/33] nixos: services: nginx: use attrset for vhosts Attribute sets compose better than lists, it was a mistake to use a list in the first place... --- modules/nixos/services/blog/default.nix | 2 +- .../nixos/services/calibre-web/default.nix | 8 ++-- .../nixos/services/drone/server/default.nix | 8 ++-- modules/nixos/services/flood/default.nix | 8 ++-- modules/nixos/services/gitea/default.nix | 12 +++--- modules/nixos/services/indexers/default.nix | 24 ++++++------ modules/nixos/services/jellyfin/default.nix | 8 ++-- modules/nixos/services/lohr/default.nix | 8 ++-- modules/nixos/services/matrix/default.nix | 20 +++++----- modules/nixos/services/miniflux/default.nix | 8 ++-- modules/nixos/services/monitoring/default.nix | 8 ++-- modules/nixos/services/navidrome/default.nix | 8 ++-- modules/nixos/services/nginx/default.nix | 38 +++++++++---------- modules/nixos/services/nix-cache/default.nix | 8 ++-- modules/nixos/services/paperless/default.nix | 8 ++-- modules/nixos/services/pirate/default.nix | 8 ++-- modules/nixos/services/podgrab/default.nix | 8 ++-- modules/nixos/services/sabnzbd/default.nix | 8 ++-- .../services/tandoor-recipes/default.nix | 8 ++-- .../nixos/services/transmission/default.nix | 8 ++-- modules/nixos/services/vikunja/default.nix | 8 ++-- .../services/woodpecker/server/default.nix | 12 +++--- 22 files changed, 118 insertions(+), 118 deletions(-) diff --git a/modules/nixos/services/blog/default.nix b/modules/nixos/services/blog/default.nix index 4b646c3..38ada5e 100644 --- a/modules/nixos/services/blog/default.nix +++ b/modules/nixos/services/blog/default.nix @@ -9,7 +9,7 @@ let root = "/var/www/${subdomain}"; }; - hostsInfo = map makeHostInfo [ "cv" "dev" "key" ]; + hostsInfo = lib.flip lib.genAttrs makeHostInfo [ "cv" "dev" "key" ]; in { options.my.services.blog = { diff --git a/modules/nixos/services/calibre-web/default.nix b/modules/nixos/services/calibre-web/default.nix index 858851c..fe53b7e 100644 --- a/modules/nixos/services/calibre-web/default.nix +++ b/modules/nixos/services/calibre-web/default.nix @@ -40,12 +40,12 @@ in # Set-up media group users.groups.media = { }; - my.services.nginx.virtualHosts = [ - { + my.services.nginx.virtualHosts = { + library = { subdomain = "library"; inherit (cfg) port; - } - ]; + }; + }; my.services.backup = { paths = [ diff --git a/modules/nixos/services/drone/server/default.nix b/modules/nixos/services/drone/server/default.nix index d651f85..2207765 100644 --- a/modules/nixos/services/drone/server/default.nix +++ b/modules/nixos/services/drone/server/default.nix @@ -45,11 +45,11 @@ in }]; }; - my.services.nginx.virtualHosts = [ - { + my.services.nginx.virtualHosts = { + drone = { subdomain = "drone"; inherit (cfg) port; - } - ]; + }; + }; }; } diff --git a/modules/nixos/services/flood/default.nix b/modules/nixos/services/flood/default.nix index ff5d941..e227dde 100644 --- a/modules/nixos/services/flood/default.nix +++ b/modules/nixos/services/flood/default.nix @@ -40,11 +40,11 @@ in }; }; - my.services.nginx.virtualHosts = [ - { + my.services.nginx.virtualHosts = { + flood = { subdomain = "flood"; inherit (cfg) port; - } - ]; + }; + }; }; } diff --git a/modules/nixos/services/gitea/default.nix b/modules/nixos/services/gitea/default.nix index 00ba941..4d5429e 100644 --- a/modules/nixos/services/gitea/default.nix +++ b/modules/nixos/services/gitea/default.nix @@ -116,18 +116,18 @@ in }; users.groups.git = { }; - my.services.nginx.virtualHosts = [ + my.services.nginx.virtualHosts = { # Proxy to Gitea - { + git = { subdomain = "git"; inherit (cfg) port; - } + }; # Redirect `gitea.` to actual forge subdomain - { + gitea = { subdomain = "gitea"; redirect = config.services.gitea.settings.server.ROOT_URL; - } - ]; + }; + }; my.services.backup = { paths = [ diff --git a/modules/nixos/services/indexers/default.nix b/modules/nixos/services/indexers/default.nix index fb06a0b..ff2d91c 100644 --- a/modules/nixos/services/indexers/default.nix +++ b/modules/nixos/services/indexers/default.nix @@ -28,12 +28,12 @@ in }; }; - my.services.nginx.virtualHosts = [ - { + my.services.nginx.virtualHosts = { + jackett = { subdomain = "jackett"; port = jackettPort; - } - ]; + }; + }; }) (lib.mkIf cfg.nzbhydra.enable { @@ -41,12 +41,12 @@ in enable = true; }; - my.services.nginx.virtualHosts = [ - { + my.services.nginx.virtualHosts = { + nzbhydra = { subdomain = "nzbhydra"; port = nzbhydraPort; - } - ]; + }; + }; }) (lib.mkIf cfg.prowlarr.enable { @@ -54,12 +54,12 @@ in enable = true; }; - my.services.nginx.virtualHosts = [ - { + my.services.nginx.virtualHosts = { + prowlarr = { subdomain = "prowlarr"; port = prowlarrPort; - } - ]; + }; + }; services.fail2ban.jails = { prowlarr = '' diff --git a/modules/nixos/services/jellyfin/default.nix b/modules/nixos/services/jellyfin/default.nix index 2fcf51e..326dab3 100644 --- a/modules/nixos/services/jellyfin/default.nix +++ b/modules/nixos/services/jellyfin/default.nix @@ -17,8 +17,8 @@ in # Set-up media group users.groups.media = { }; - my.services.nginx.virtualHosts = [ - { + my.services.nginx.virtualHosts = { + jellyfin = { subdomain = "jellyfin"; port = 8096; extraConfig = { @@ -33,7 +33,7 @@ in proxyWebsockets = true; }; }; - } - ]; + }; + }; }; } diff --git a/modules/nixos/services/lohr/default.nix b/modules/nixos/services/lohr/default.nix index 245567c..af292cc 100644 --- a/modules/nixos/services/lohr/default.nix +++ b/modules/nixos/services/lohr/default.nix @@ -98,11 +98,11 @@ in }; users.groups.lohr = { }; - my.services.nginx.virtualHosts = [ - { + my.services.nginx.virtualHosts = { + lohr = { subdomain = "lohr"; inherit (cfg) port; - } - ]; + }; + }; }; } diff --git a/modules/nixos/services/matrix/default.nix b/modules/nixos/services/matrix/default.nix index 52b60c5..3328747 100644 --- a/modules/nixos/services/matrix/default.nix +++ b/modules/nixos/services/matrix/default.nix @@ -117,9 +117,9 @@ in }; }; - my.services.nginx.virtualHosts = [ + my.services.nginx.virtualHosts = { # Element Web app deployment - { + chat = { subdomain = "chat"; root = pkgs.element-web.override { conf = { @@ -145,22 +145,22 @@ in }; }; }; - } + }; # Dummy VHosts for port collision detection - { + matrix-federation = { subdomain = "matrix-federation"; port = federationPort.private; - } - { + }; + matrix-client = { subdomain = "matrix-client"; port = clientPort.private; - } + }; # Sliding sync - { + matrix-sync = { subdomain = "matrix-sync"; inherit (cfg.slidingSync) port; - } - ]; + }; + }; # Those are too complicated to use my wrapper... services.nginx.virtualHosts = { diff --git a/modules/nixos/services/miniflux/default.nix b/modules/nixos/services/miniflux/default.nix index 6d9ffc8..07eb6f8 100644 --- a/modules/nixos/services/miniflux/default.nix +++ b/modules/nixos/services/miniflux/default.nix @@ -43,11 +43,11 @@ in }; }; - my.services.nginx.virtualHosts = [ - { + my.services.nginx.virtualHosts = { + reader = { subdomain = "reader"; inherit (cfg) port; - } - ]; + }; + }; }; } diff --git a/modules/nixos/services/monitoring/default.nix b/modules/nixos/services/monitoring/default.nix index 829bfe0..2f23ff0 100644 --- a/modules/nixos/services/monitoring/default.nix +++ b/modules/nixos/services/monitoring/default.nix @@ -125,11 +125,11 @@ in ]; }; - my.services.nginx.virtualHosts = [ - { + my.services.nginx.virtualHosts = { + monitoring = { subdomain = "monitoring"; inherit (cfg.grafana) port; - } - ]; + }; + }; }; } diff --git a/modules/nixos/services/navidrome/default.nix b/modules/nixos/services/navidrome/default.nix index 6c001fd..92f9fd2 100644 --- a/modules/nixos/services/navidrome/default.nix +++ b/modules/nixos/services/navidrome/default.nix @@ -47,11 +47,11 @@ in }; }; - my.services.nginx.virtualHosts = [ - { + my.services.nginx.virtualHosts = { + music = { subdomain = "music"; inherit (cfg) port; - } - ]; + }; + }; }; } diff --git a/modules/nixos/services/nginx/default.nix b/modules/nixos/services/nginx/default.nix index 6ca2e42..53c947b 100644 --- a/modules/nixos/services/nginx/default.nix +++ b/modules/nixos/services/nginx/default.nix @@ -97,19 +97,19 @@ in }; virtualHosts = mkOption { - type = types.listOf virtualHostOption; - default = [ ]; + type = types.attrsOf virtualHostOption; + default = { }; example = litteralExample '' - [ - { - subdomain = "gitea"; + { + gitea = { + subdomain = "git"; port = 8080; - } - { + }; + dev = { subdomain = "dev"; root = "/var/www/dev"; - } - { + }; + jellyfin = { subdomain = "jellyfin"; port = 8096; extraConfig = { @@ -118,8 +118,8 @@ in proxyWebsockets = true; }; }; - } - ] + }; + } ''; description = '' List of virtual hosts to set-up using default settings. @@ -190,7 +190,7 @@ in config = lib.mkIf cfg.enable { assertions = [ ] - ++ (lib.flip builtins.map cfg.virtualHosts ({ subdomain, ... } @ args: + ++ (lib.flip lib.mapAttrsToList cfg.virtualHosts (_: { subdomain, ... } @ args: let conflicts = [ "port" "root" "socket" "redirect" ]; optionsNotNull = builtins.map (v: args.${v} != null) conflicts; @@ -209,7 +209,7 @@ in ports = lib.my.mapFilter (v: v != null) ({ port, ... }: port) - cfg.virtualHosts; + (lib.attrValues cfg.virtualHosts); portCounts = lib.my.countValues ports; nonUniquesCounts = lib.filterAttrs (_: v: v != 1) portCounts; nonUniques = builtins.attrNames nonUniquesCounts; @@ -221,7 +221,7 @@ in map mkAssertion nonUniques ) ++ ( let - subs = map ({ subdomain, ... }: subdomain) cfg.virtualHosts; + subs = lib.mapAttrsToList (_: { subdomain, ... }: subdomain) cfg.virtualHosts; subsCounts = lib.my.countValues subs; nonUniquesCounts = lib.filterAttrs (_: v: v != 1) subsCounts; nonUniques = builtins.attrNames nonUniquesCounts; @@ -325,7 +325,7 @@ in ]) ); in - lib.my.genAttrs' cfg.virtualHosts mkVHost; + lib.my.genAttrs' (lib.attrValues cfg.virtualHosts) mkVHost; sso = { enable = true; @@ -403,12 +403,12 @@ in }; }; - my.services.nginx.virtualHosts = [ - { + my.services.nginx.virtualHosts = { + login = { subdomain = "login"; inherit (cfg.sso) port; - } - ]; + }; + }; networking.firewall.allowedTCPPorts = [ 80 443 ]; diff --git a/modules/nixos/services/nix-cache/default.nix b/modules/nixos/services/nix-cache/default.nix index b3bdbf3..5517a78 100644 --- a/modules/nixos/services/nix-cache/default.nix +++ b/modules/nixos/services/nix-cache/default.nix @@ -43,11 +43,11 @@ in signKeyPath = cfg.secretKeyFile; }; - my.services.nginx.virtualHosts = [ - { + my.services.nginx.virtualHosts = { + cache = { subdomain = "cache"; inherit (cfg) port; - } - ]; + }; + }; }; } diff --git a/modules/nixos/services/paperless/default.nix b/modules/nixos/services/paperless/default.nix index 90f6b0c..87a816a 100644 --- a/modules/nixos/services/paperless/default.nix +++ b/modules/nixos/services/paperless/default.nix @@ -143,8 +143,8 @@ in extraGroups = [ "media" ]; }; - my.services.nginx.virtualHosts = [ - { + my.services.nginx.virtualHosts = { + paperless = { subdomain = "paperless"; inherit (cfg) port; sso = { @@ -155,8 +155,8 @@ in extraConfig = { locations."/".proxyWebsockets = true; }; - } - ]; + }; + }; my.services.backup = { paths = [ diff --git a/modules/nixos/services/pirate/default.nix b/modules/nixos/services/pirate/default.nix index 59f9794..88a2250 100644 --- a/modules/nixos/services/pirate/default.nix +++ b/modules/nixos/services/pirate/default.nix @@ -21,12 +21,12 @@ let }; mkRedirection = service: { - my.services.nginx.virtualHosts = [ - { + my.services.nginx.virtualHosts = { + ${service} = { subdomain = service; port = ports.${service}; - } - ]; + }; + }; }; mkFail2Ban = service: lib.mkIf cfg.${service}.enable { diff --git a/modules/nixos/services/podgrab/default.nix b/modules/nixos/services/podgrab/default.nix index 9793d60..e59b20d 100644 --- a/modules/nixos/services/podgrab/default.nix +++ b/modules/nixos/services/podgrab/default.nix @@ -31,11 +31,11 @@ in inherit (cfg) passwordFile port; }; - my.services.nginx.virtualHosts = [ - { + my.services.nginx.virtualHosts = { + podgrab = { subdomain = "podgrab"; inherit (cfg) port; - } - ]; + }; + }; }; } diff --git a/modules/nixos/services/sabnzbd/default.nix b/modules/nixos/services/sabnzbd/default.nix index 7ab145f..42058e7 100644 --- a/modules/nixos/services/sabnzbd/default.nix +++ b/modules/nixos/services/sabnzbd/default.nix @@ -18,12 +18,12 @@ in # Set-up media group users.groups.media = { }; - my.services.nginx.virtualHosts = [ - { + my.services.nginx.virtualHosts = { + sabnzbd = { subdomain = "sabnzbd"; inherit port; - } - ]; + }; + }; services.fail2ban.jails = { sabnzbd = '' diff --git a/modules/nixos/services/tandoor-recipes/default.nix b/modules/nixos/services/tandoor-recipes/default.nix index 541e198..353fac3 100644 --- a/modules/nixos/services/tandoor-recipes/default.nix +++ b/modules/nixos/services/tandoor-recipes/default.nix @@ -70,11 +70,11 @@ in ]; }; - my.services.nginx.virtualHosts = [ - { + my.services.nginx.virtualHosts = { + recipes = { subdomain = "recipes"; inherit (cfg) port; - } - ]; + }; + }; }; } diff --git a/modules/nixos/services/transmission/default.nix b/modules/nixos/services/transmission/default.nix index 28df477..ce7f9e6 100644 --- a/modules/nixos/services/transmission/default.nix +++ b/modules/nixos/services/transmission/default.nix @@ -80,12 +80,12 @@ in # Default transmission webui, I prefer combustion but its development # seems to have stalled - my.services.nginx.virtualHosts = [ - { + my.services.nginx.virtualHosts = { + transmission = { subdomain = "transmission"; inherit (cfg) port; - } - ]; + }; + }; networking.firewall = { allowedTCPPorts = [ cfg.peerPort ]; diff --git a/modules/nixos/services/vikunja/default.nix b/modules/nixos/services/vikunja/default.nix index 8c051b0..425698d 100644 --- a/modules/nixos/services/vikunja/default.nix +++ b/modules/nixos/services/vikunja/default.nix @@ -59,8 +59,8 @@ in }; # This is a weird setup - my.services.nginx.virtualHosts = [ - { + my.services.nginx.virtualHosts = { + vikunja = { inherit subdomain; # Serve the root for the web-ui root = config.services.vikunja.package-frontend; @@ -80,8 +80,8 @@ in }; }; }; - } - ]; + }; + }; systemd.services.vikunja-api = { serviceConfig = { diff --git a/modules/nixos/services/woodpecker/server/default.nix b/modules/nixos/services/woodpecker/server/default.nix index cebbc9b..b5ec0d8 100644 --- a/modules/nixos/services/woodpecker/server/default.nix +++ b/modules/nixos/services/woodpecker/server/default.nix @@ -52,16 +52,16 @@ in }]; }; - my.services.nginx.virtualHosts = [ - { + my.services.nginx.virtualHosts = { + woodpecker = { subdomain = "woodpecker"; inherit (cfg) port; - } + }; # I might want to be able to RPC from other hosts in the future - { + woodpecker-rpc = { subdomain = "woodpecker-rpc"; port = cfg.rpcPort; - } - ]; + }; + }; }; } From b7a4bc063fb6b26064c1f626aa3bd1b3960c85b5 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Mon, 25 Dec 2023 19:28:53 +0100 Subject: [PATCH 06/33] nixos: services: nginx: add default subdomain In almost all cases, the subdomain should be the same as the attribute name... --- modules/nixos/services/nginx/default.nix | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/nixos/services/nginx/default.nix b/modules/nixos/services/nginx/default.nix index 53c947b..e916c9c 100644 --- a/modules/nixos/services/nginx/default.nix +++ b/modules/nixos/services/nginx/default.nix @@ -5,10 +5,11 @@ let domain = config.networking.domain; - virtualHostOption = with lib; types.submodule { + virtualHostOption = with lib; types.submodule ({ name, ... }: { options = { subdomain = mkOption { type = types.str; + default = name; example = "dev"; description = '' Which subdomain, under config.networking.domain, to use @@ -72,7 +73,7 @@ let ''; }; }; - }; + }); in { imports = [ @@ -106,11 +107,9 @@ in port = 8080; }; dev = { - subdomain = "dev"; root = "/var/www/dev"; }; jellyfin = { - subdomain = "jellyfin"; port = 8096; extraConfig = { locations."/socket" = { From 6948424b81e41c4335c9ff13d95ce1534703d644 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Mon, 25 Dec 2023 19:42:20 +0100 Subject: [PATCH 07/33] nixos: services: remove redundant subdomains See previous commit for the defaults. --- modules/nixos/services/blog/default.nix | 1 - modules/nixos/services/calibre-web/default.nix | 1 - modules/nixos/services/drone/server/default.nix | 1 - modules/nixos/services/flood/default.nix | 1 - modules/nixos/services/gitea/default.nix | 2 -- modules/nixos/services/indexers/default.nix | 3 --- modules/nixos/services/jellyfin/default.nix | 1 - modules/nixos/services/lohr/default.nix | 1 - modules/nixos/services/matrix/default.nix | 4 ---- modules/nixos/services/miniflux/default.nix | 1 - modules/nixos/services/monitoring/default.nix | 1 - modules/nixos/services/navidrome/default.nix | 1 - modules/nixos/services/nginx/default.nix | 1 - modules/nixos/services/nix-cache/default.nix | 1 - modules/nixos/services/paperless/default.nix | 1 - modules/nixos/services/pirate/default.nix | 1 - modules/nixos/services/podgrab/default.nix | 1 - modules/nixos/services/sabnzbd/default.nix | 1 - modules/nixos/services/tandoor-recipes/default.nix | 1 - modules/nixos/services/transmission/default.nix | 1 - modules/nixos/services/vikunja/default.nix | 3 +-- modules/nixos/services/woodpecker/server/default.nix | 2 -- 22 files changed, 1 insertion(+), 30 deletions(-) diff --git a/modules/nixos/services/blog/default.nix b/modules/nixos/services/blog/default.nix index 38ada5e..3e68df2 100644 --- a/modules/nixos/services/blog/default.nix +++ b/modules/nixos/services/blog/default.nix @@ -5,7 +5,6 @@ let domain = config.networking.domain; makeHostInfo = subdomain: { - inherit subdomain; root = "/var/www/${subdomain}"; }; diff --git a/modules/nixos/services/calibre-web/default.nix b/modules/nixos/services/calibre-web/default.nix index fe53b7e..b7bf9df 100644 --- a/modules/nixos/services/calibre-web/default.nix +++ b/modules/nixos/services/calibre-web/default.nix @@ -42,7 +42,6 @@ in my.services.nginx.virtualHosts = { library = { - subdomain = "library"; inherit (cfg) port; }; }; diff --git a/modules/nixos/services/drone/server/default.nix b/modules/nixos/services/drone/server/default.nix index 2207765..a3a1e49 100644 --- a/modules/nixos/services/drone/server/default.nix +++ b/modules/nixos/services/drone/server/default.nix @@ -47,7 +47,6 @@ in my.services.nginx.virtualHosts = { drone = { - subdomain = "drone"; inherit (cfg) port; }; }; diff --git a/modules/nixos/services/flood/default.nix b/modules/nixos/services/flood/default.nix index e227dde..155e73d 100644 --- a/modules/nixos/services/flood/default.nix +++ b/modules/nixos/services/flood/default.nix @@ -42,7 +42,6 @@ in my.services.nginx.virtualHosts = { flood = { - subdomain = "flood"; inherit (cfg) port; }; }; diff --git a/modules/nixos/services/gitea/default.nix b/modules/nixos/services/gitea/default.nix index 4d5429e..4a8a3bb 100644 --- a/modules/nixos/services/gitea/default.nix +++ b/modules/nixos/services/gitea/default.nix @@ -119,12 +119,10 @@ in my.services.nginx.virtualHosts = { # Proxy to Gitea git = { - subdomain = "git"; inherit (cfg) port; }; # Redirect `gitea.` to actual forge subdomain gitea = { - subdomain = "gitea"; redirect = config.services.gitea.settings.server.ROOT_URL; }; }; diff --git a/modules/nixos/services/indexers/default.nix b/modules/nixos/services/indexers/default.nix index ff2d91c..8a42345 100644 --- a/modules/nixos/services/indexers/default.nix +++ b/modules/nixos/services/indexers/default.nix @@ -30,7 +30,6 @@ in my.services.nginx.virtualHosts = { jackett = { - subdomain = "jackett"; port = jackettPort; }; }; @@ -43,7 +42,6 @@ in my.services.nginx.virtualHosts = { nzbhydra = { - subdomain = "nzbhydra"; port = nzbhydraPort; }; }; @@ -56,7 +54,6 @@ in my.services.nginx.virtualHosts = { prowlarr = { - subdomain = "prowlarr"; port = prowlarrPort; }; }; diff --git a/modules/nixos/services/jellyfin/default.nix b/modules/nixos/services/jellyfin/default.nix index 326dab3..9efe11e 100644 --- a/modules/nixos/services/jellyfin/default.nix +++ b/modules/nixos/services/jellyfin/default.nix @@ -19,7 +19,6 @@ in my.services.nginx.virtualHosts = { jellyfin = { - subdomain = "jellyfin"; port = 8096; extraConfig = { locations."/" = { diff --git a/modules/nixos/services/lohr/default.nix b/modules/nixos/services/lohr/default.nix index af292cc..dd4eea8 100644 --- a/modules/nixos/services/lohr/default.nix +++ b/modules/nixos/services/lohr/default.nix @@ -100,7 +100,6 @@ in my.services.nginx.virtualHosts = { lohr = { - subdomain = "lohr"; inherit (cfg) port; }; }; diff --git a/modules/nixos/services/matrix/default.nix b/modules/nixos/services/matrix/default.nix index 3328747..bd2a017 100644 --- a/modules/nixos/services/matrix/default.nix +++ b/modules/nixos/services/matrix/default.nix @@ -120,7 +120,6 @@ in my.services.nginx.virtualHosts = { # Element Web app deployment chat = { - subdomain = "chat"; root = pkgs.element-web.override { conf = { default_server_config = { @@ -148,16 +147,13 @@ in }; # Dummy VHosts for port collision detection matrix-federation = { - subdomain = "matrix-federation"; port = federationPort.private; }; matrix-client = { - subdomain = "matrix-client"; port = clientPort.private; }; # Sliding sync matrix-sync = { - subdomain = "matrix-sync"; inherit (cfg.slidingSync) port; }; }; diff --git a/modules/nixos/services/miniflux/default.nix b/modules/nixos/services/miniflux/default.nix index 07eb6f8..5104c8b 100644 --- a/modules/nixos/services/miniflux/default.nix +++ b/modules/nixos/services/miniflux/default.nix @@ -45,7 +45,6 @@ in my.services.nginx.virtualHosts = { reader = { - subdomain = "reader"; inherit (cfg) port; }; }; diff --git a/modules/nixos/services/monitoring/default.nix b/modules/nixos/services/monitoring/default.nix index 2f23ff0..49919c1 100644 --- a/modules/nixos/services/monitoring/default.nix +++ b/modules/nixos/services/monitoring/default.nix @@ -127,7 +127,6 @@ in my.services.nginx.virtualHosts = { monitoring = { - subdomain = "monitoring"; inherit (cfg.grafana) port; }; }; diff --git a/modules/nixos/services/navidrome/default.nix b/modules/nixos/services/navidrome/default.nix index 92f9fd2..944a97a 100644 --- a/modules/nixos/services/navidrome/default.nix +++ b/modules/nixos/services/navidrome/default.nix @@ -49,7 +49,6 @@ in my.services.nginx.virtualHosts = { music = { - subdomain = "music"; inherit (cfg) port; }; }; diff --git a/modules/nixos/services/nginx/default.nix b/modules/nixos/services/nginx/default.nix index e916c9c..ae6c0dc 100644 --- a/modules/nixos/services/nginx/default.nix +++ b/modules/nixos/services/nginx/default.nix @@ -404,7 +404,6 @@ in my.services.nginx.virtualHosts = { login = { - subdomain = "login"; inherit (cfg.sso) port; }; }; diff --git a/modules/nixos/services/nix-cache/default.nix b/modules/nixos/services/nix-cache/default.nix index 5517a78..1ce3161 100644 --- a/modules/nixos/services/nix-cache/default.nix +++ b/modules/nixos/services/nix-cache/default.nix @@ -45,7 +45,6 @@ in my.services.nginx.virtualHosts = { cache = { - subdomain = "cache"; inherit (cfg) port; }; }; diff --git a/modules/nixos/services/paperless/default.nix b/modules/nixos/services/paperless/default.nix index 87a816a..c40e895 100644 --- a/modules/nixos/services/paperless/default.nix +++ b/modules/nixos/services/paperless/default.nix @@ -145,7 +145,6 @@ in my.services.nginx.virtualHosts = { paperless = { - subdomain = "paperless"; inherit (cfg) port; sso = { enable = true; diff --git a/modules/nixos/services/pirate/default.nix b/modules/nixos/services/pirate/default.nix index 88a2250..e500b54 100644 --- a/modules/nixos/services/pirate/default.nix +++ b/modules/nixos/services/pirate/default.nix @@ -23,7 +23,6 @@ let mkRedirection = service: { my.services.nginx.virtualHosts = { ${service} = { - subdomain = service; port = ports.${service}; }; }; diff --git a/modules/nixos/services/podgrab/default.nix b/modules/nixos/services/podgrab/default.nix index e59b20d..5ceebb6 100644 --- a/modules/nixos/services/podgrab/default.nix +++ b/modules/nixos/services/podgrab/default.nix @@ -33,7 +33,6 @@ in my.services.nginx.virtualHosts = { podgrab = { - subdomain = "podgrab"; inherit (cfg) port; }; }; diff --git a/modules/nixos/services/sabnzbd/default.nix b/modules/nixos/services/sabnzbd/default.nix index 42058e7..9e0d9c3 100644 --- a/modules/nixos/services/sabnzbd/default.nix +++ b/modules/nixos/services/sabnzbd/default.nix @@ -20,7 +20,6 @@ in my.services.nginx.virtualHosts = { sabnzbd = { - subdomain = "sabnzbd"; inherit port; }; }; diff --git a/modules/nixos/services/tandoor-recipes/default.nix b/modules/nixos/services/tandoor-recipes/default.nix index 353fac3..f5dc2db 100644 --- a/modules/nixos/services/tandoor-recipes/default.nix +++ b/modules/nixos/services/tandoor-recipes/default.nix @@ -72,7 +72,6 @@ in my.services.nginx.virtualHosts = { recipes = { - subdomain = "recipes"; inherit (cfg) port; }; }; diff --git a/modules/nixos/services/transmission/default.nix b/modules/nixos/services/transmission/default.nix index ce7f9e6..aeb88b7 100644 --- a/modules/nixos/services/transmission/default.nix +++ b/modules/nixos/services/transmission/default.nix @@ -82,7 +82,6 @@ in # seems to have stalled my.services.nginx.virtualHosts = { transmission = { - subdomain = "transmission"; inherit (cfg) port; }; }; diff --git a/modules/nixos/services/vikunja/default.nix b/modules/nixos/services/vikunja/default.nix index 425698d..9767d00 100644 --- a/modules/nixos/services/vikunja/default.nix +++ b/modules/nixos/services/vikunja/default.nix @@ -60,8 +60,7 @@ in # This is a weird setup my.services.nginx.virtualHosts = { - vikunja = { - inherit subdomain; + ${subdomain} = { # Serve the root for the web-ui root = config.services.vikunja.package-frontend; diff --git a/modules/nixos/services/woodpecker/server/default.nix b/modules/nixos/services/woodpecker/server/default.nix index b5ec0d8..f02a5c5 100644 --- a/modules/nixos/services/woodpecker/server/default.nix +++ b/modules/nixos/services/woodpecker/server/default.nix @@ -54,12 +54,10 @@ in my.services.nginx.virtualHosts = { woodpecker = { - subdomain = "woodpecker"; inherit (cfg) port; }; # I might want to be able to RPC from other hosts in the future woodpecker-rpc = { - subdomain = "woodpecker-rpc"; port = cfg.rpcPort; }; }; From 71ee178510edc5d66b07bd53b58ba85a7591bbfe Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Mon, 25 Dec 2023 19:43:44 +0100 Subject: [PATCH 08/33] nixos: services: nginx: fix SSO subdomain --- modules/nixos/services/nginx/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/nixos/services/nginx/default.nix b/modules/nixos/services/nginx/default.nix index ae6c0dc..7980ad9 100644 --- a/modules/nixos/services/nginx/default.nix +++ b/modules/nixos/services/nginx/default.nix @@ -403,7 +403,7 @@ in }; my.services.nginx.virtualHosts = { - login = { + ${cfg.sso.subdomain} = { inherit (cfg.sso) port; }; }; From 932717b7548ae5f7a7fdec3e7e2d78d0fca6ef68 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Tue, 26 Dec 2023 15:17:03 +0100 Subject: [PATCH 09/33] nixos: services: jellyfin: loosen umask I just noticed that all the metadata files Jellyfin stores have very restrictive ACLs. The whole point of the `media` group is to make my HTPC eco-system work together. In particular this should allow Sonarr and friends to delete folders without manual intervention. --- modules/nixos/services/jellyfin/default.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/nixos/services/jellyfin/default.nix b/modules/nixos/services/jellyfin/default.nix index 9efe11e..f5aaa99 100644 --- a/modules/nixos/services/jellyfin/default.nix +++ b/modules/nixos/services/jellyfin/default.nix @@ -17,6 +17,13 @@ in # Set-up media group users.groups.media = { }; + systemd.services.jellyfin = { + serviceConfig = { + # Loose umask to make Jellyfin metadata more broadly readable + UMask = lib.mkForce "0002"; + }; + }; + my.services.nginx.virtualHosts = { jellyfin = { port = 8096; From 39eba647acacdf2bb2aafb00be694fa5c2e0726f Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Wed, 3 Jan 2024 14:15:42 +0000 Subject: [PATCH 10/33] hosts: nixos: aramis: home: use 'pinentry-qt' The GTK2 variant has been removed [1]. I may revise this in the future if [2] is merged (I'd like to try `pinentry-rofi` [3]). [1]: https://github.com/NixOS/nixpkgs/pull/270266 [2]: https://github.com/NixOS/nixpkgs/pull/277221 [3]: https://github.com/plattfot/pinentry-rofi --- hosts/nixos/aramis/home.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hosts/nixos/aramis/home.nix b/hosts/nixos/aramis/home.nix index 66a0892..dfe9dbe 100644 --- a/hosts/nixos/aramis/home.nix +++ b/hosts/nixos/aramis/home.nix @@ -2,7 +2,7 @@ { my.home = { # Use graphical pinentry - bitwarden.pinentry = "gtk2"; + bitwarden.pinentry = "qt"; # Ebook library calibre.enable = true; # Some amount of social life @@ -14,7 +14,7 @@ # Blue light filter gammastep.enable = true; # Use a small popup to enter passwords - gpg.pinentry = "gtk2"; + gpg.pinentry = "qt"; # Machine specific packages packages.additionalPackages = with pkgs; [ element-desktop # Matrix client From a93dc2935bd81f3583182c34e74231b4a1fb960f Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Wed, 3 Jan 2024 14:00:58 +0000 Subject: [PATCH 11/33] flake: add explicit 'systems' input --- flake.lock | 8 ++++++-- flake.nix | 10 ++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/flake.lock b/flake.lock index adff398..ef07b15 100644 --- a/flake.lock +++ b/flake.lock @@ -86,7 +86,9 @@ }, "futils": { "inputs": { - "systems": "systems" + "systems": [ + "systems" + ] }, "locked": { "lastModified": 1701680307, @@ -214,7 +216,8 @@ "home-manager": "home-manager", "nixpkgs": "nixpkgs", "nur": "nur", - "pre-commit-hooks": "pre-commit-hooks" + "pre-commit-hooks": "pre-commit-hooks", + "systems": "systems" } }, "systems": { @@ -228,6 +231,7 @@ }, "original": { "owner": "nix-systems", + "ref": "main", "repo": "default", "type": "github" } diff --git a/flake.nix b/flake.nix index 8e46ea3..85fafbb 100644 --- a/flake.nix +++ b/flake.nix @@ -27,6 +27,9 @@ owner = "numtide"; repo = "flake-utils"; ref = "main"; + inputs = { + systems.follows = "systems"; + }; }; home-manager = { @@ -64,6 +67,13 @@ nixpkgs-stable.follows = "nixpkgs"; }; }; + + systems = { + type = "github"; + owner = "nix-systems"; + repo = "default"; + ref = "main"; + }; }; # Can't eta-reduce a flake outputs... From e02da7ec693b1a5f9e0119fed1f564ec01025c50 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Wed, 3 Jan 2024 14:05:46 +0000 Subject: [PATCH 12/33] flake: bump inputs --- flake.lock | 45 ++++++++++++++++++++++++--------------------- flake.nix | 1 + 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/flake.lock b/flake.lock index ef07b15..5e4a413 100644 --- a/flake.lock +++ b/flake.lock @@ -8,14 +8,17 @@ ], "nixpkgs": [ "nixpkgs" + ], + "systems": [ + "systems" ] }, "locked": { - "lastModified": 1701216516, - "narHash": "sha256-jKSeJn+7hZ1dZdiH1L+NWUGT2i/BGomKAJ54B9kT06Q=", + "lastModified": 1703433843, + "narHash": "sha256-nmtA4KqFboWxxoOAA6Y1okHbZh+HsXaMPFkYHsoDRDw=", "owner": "ryantm", "repo": "agenix", - "rev": "13ac9ac6d68b9a0896e3d43a082947233189e247", + "rev": "417caa847f9383e111d1397039c9d4337d024bf0", "type": "github" }, "original": { @@ -33,11 +36,11 @@ ] }, "locked": { - "lastModified": 1673295039, - "narHash": "sha256-AsdYgE8/GPwcelGgrntlijMg4t3hLFJFCRF3tL5WVjA=", + "lastModified": 1700795494, + "narHash": "sha256-gzGLZSiOhf155FW7262kdHo2YDeugp3VuIFb4/GGng0=", "owner": "lnl7", "repo": "nix-darwin", - "rev": "87b9d090ad39b25b2400029c64825fc2a8868943", + "rev": "4b9b83d5a92e8c1fbfd8eb27eda375908c11ec4d", "type": "github" }, "original": { @@ -70,11 +73,11 @@ ] }, "locked": { - "lastModified": 1701473968, - "narHash": "sha256-YcVE5emp1qQ8ieHUnxt1wCZCC3ZfAS+SRRWZ2TMda7E=", + "lastModified": 1704152458, + "narHash": "sha256-DS+dGw7SKygIWf9w4eNBUZsK+4Ug27NwEWmn2tnbycg=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "34fed993f1674c8d06d58b37ce1e0fe5eebcb9f5", + "rev": "88a2cd8166694ba0b6cb374700799cec53aef527", "type": "github" }, "original": { @@ -133,11 +136,11 @@ ] }, "locked": { - "lastModified": 1702538064, - "narHash": "sha256-At5GwJPu2tzvS9dllhBoZmqK6lkkh/sOp2YefWRlaL8=", + "lastModified": 1704276313, + "narHash": "sha256-4eD4RaAKHLj0ztw5pQcNFs3hGpxrsYb0e9Qir+Ute+w=", "owner": "nix-community", "repo": "home-manager", - "rev": "0e2e443ff24f9d75925e91b89d1da44b863734af", + "rev": "4d8f90205c6c90be2e81d94d0e5eedf71c1ba34e", "type": "github" }, "original": { @@ -149,11 +152,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1702312524, - "narHash": "sha256-gkZJRDBUCpTPBvQk25G0B7vfbpEYM5s5OZqghkjZsnE=", + "lastModified": 1703961334, + "narHash": "sha256-M1mV/Cq+pgjk0rt6VxoyyD+O8cOUiai8t9Q6Yyq4noY=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "a9bf124c46ef298113270b1f84a164865987a91c", + "rev": "b0d36bd0a420ecee3bc916c91886caca87c894e9", "type": "github" }, "original": { @@ -165,11 +168,11 @@ }, "nur": { "locked": { - "lastModified": 1702558663, - "narHash": "sha256-MHq/DdwsBwsTRqwFg1JuFtcoGArgvaH/XwbxgWQ4Zn0=", + "lastModified": 1704289500, + "narHash": "sha256-SMoojjdEMgf6GtPh5vzofdeev4nyM+vBi2J6Z/Sufco=", "owner": "nix-community", "repo": "NUR", - "rev": "b839a2bae27c0c14dd99dcc1f6d18f83b0af59bd", + "rev": "a18213c74e43dd6e941c41d77382377938c77caf", "type": "github" }, "original": { @@ -194,11 +197,11 @@ ] }, "locked": { - "lastModified": 1702456155, - "narHash": "sha256-I2XhXGAecdGlqi6hPWYT83AQtMgL+aa3ulA85RAEgOk=", + "lastModified": 1703939133, + "narHash": "sha256-Gxe+mfOT6bL7wLC/tuT2F+V+Sb44jNr8YsJ3cyIl4Mo=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "007a45d064c1c32d04e1b8a0de5ef00984c419bc", + "rev": "9d3d7e18c6bc4473d7520200d4ddab12f8402d38", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 85fafbb..9c29183 100644 --- a/flake.nix +++ b/flake.nix @@ -9,6 +9,7 @@ inputs = { home-manager.follows = "home-manager"; nixpkgs.follows = "nixpkgs"; + systems.follows = "systems"; }; }; From bddcab110d2e85679b10ba6f7b058ac18e79bced Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Wed, 3 Jan 2024 15:58:34 +0000 Subject: [PATCH 13/33] pkgs: matrix-notifier: 0.3.0 -> 0.4.0 --- pkgs/matrix-notifier/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/matrix-notifier/default.nix b/pkgs/matrix-notifier/default.nix index a96cb61..aba093f 100644 --- a/pkgs/matrix-notifier/default.nix +++ b/pkgs/matrix-notifier/default.nix @@ -1,13 +1,13 @@ { lib, curl, jq, fetchFromGitHub, makeWrapper, pandoc, stdenvNoCC }: stdenvNoCC.mkDerivation rec { pname = "matrix-notifier"; - version = "0.3.0"; + version = "0.4.0"; src = fetchFromGitHub { owner = "ambroisie"; repo = "matrix-notifier"; rev = "v${version}"; - hash = "sha256-NE9RO0ep2ibrT9EUPGTnUE3ofdNTCHwelxnX9tCflg0="; + hash = "sha256-6KHteQx0bHodpNp7cuUIGM7uBRPaj386n2t5yz6umpY="; }; nativeBuildInputs = [ From aa1336bb8d8ff501d5977481298b4229d472416e Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Wed, 3 Jan 2024 16:49:19 +0000 Subject: [PATCH 14/33] modules: add common This should define modules that are identical, or very similar. The driving force is to be able to use `my.profiles` on home-manager and NixOS without repeating myself. In the future I might migrate other modules, such as `nixos/system/nix`... --- modules/common/default.nix | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 modules/common/default.nix diff --git a/modules/common/default.nix b/modules/common/default.nix new file mode 100644 index 0000000..d0c90de --- /dev/null +++ b/modules/common/default.nix @@ -0,0 +1,31 @@ +# Modules that are common to various module systems +# Usually with very small differences, if any, between them. +{ lib, type ? null, ... }: +let + allowedTypes = [ + "nixos" + "home" + "darwin" + ]; + + allowedTypesString = lib.concatStringSep ", " (builtins.map lib.escapeNixString allowedTypes); +in +{ + config = { + assertions = [ + { + assertion = type != null; + message = '' + You must provide `type` as part of specialArgs to use the common modules. + It must be one of ${allowedTypesString}. + ''; + } + { + assertion = type != null -> builtins.elem type allowedTypes; + message = '' + `type` specialArgs must be one of ${allowedTypesString}. + ''; + } + ]; + }; +} From c27b83652a02dea98c88b9b992443e7c579aa8eb Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Wed, 3 Jan 2024 16:50:05 +0000 Subject: [PATCH 15/33] nixos: home: import common modules --- modules/nixos/home/default.nix | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/nixos/home/default.nix b/modules/nixos/home/default.nix index fe00704..2d323d1 100644 --- a/modules/nixos/home/default.nix +++ b/modules/nixos/home/default.nix @@ -14,7 +14,12 @@ in config = lib.mkIf cfg.enable { home-manager = { # Not a fan of out-of-directory imports, but this is a good exception - users.${config.my.user.name} = import "${inputs.self}/modules/home"; + users.${config.my.user.name} = { + imports = [ + "${inputs.self}/modules/common"; + "${inputs.self}/modules/home"; + ]; + }; # Nix Flakes compatibility useGlobalPkgs = true; @@ -23,6 +28,8 @@ in # Forward inputs to home-manager configuration extraSpecialArgs = { inherit inputs; + # For consumption by common modules + type = "home"; }; }; }; From e9abcb0307c2a74b03a5976309da945686d8dff8 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Wed, 3 Jan 2024 16:50:16 +0000 Subject: [PATCH 16/33] flake: home-manager: import common modules --- flake/home-manager.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/flake/home-manager.nix b/flake/home-manager.nix index 34af375..2f7e245 100644 --- a/flake/home-manager.nix +++ b/flake/home-manager.nix @@ -14,6 +14,8 @@ let # Enable home-manager programs.home-manager.enable = true; } + # Import common modules + "${self}/modules/common" ]; mkHome = name: system: inputs.home-manager.lib.homeManagerConfiguration { @@ -36,6 +38,8 @@ let extraSpecialArgs = { # Inject inputs to use them in global registry inherit inputs; + # For consumption by common modules + type = "home"; }; }; From 8dcbd6e8500821b280290020ff20e4d847bc497b Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Wed, 3 Jan 2024 16:50:22 +0000 Subject: [PATCH 17/33] flake: nixos: import common modules --- flake/nixos.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/flake/nixos.nix b/flake/nixos.nix index b48b551..c5d9ede 100644 --- a/flake/nixos.nix +++ b/flake/nixos.nix @@ -12,6 +12,8 @@ let } # Include generic settings "${self}/modules/nixos" + # Import common modules + "${self}/modules/common" ]; buildHost = name: system: lib.nixosSystem { @@ -24,6 +26,8 @@ let inherit (self) lib; # Inject inputs to use them in global registry inherit inputs; + # For consumption by common modules + type = "nixos"; }; }; in From ef55541337037d22745efaf5b6b9573ca695398e Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Wed, 3 Jan 2024 16:51:34 +0000 Subject: [PATCH 18/33] common: add profiles I will be migrating each sub-module one by one. --- modules/common/default.nix | 4 ++++ modules/common/profiles/default.nix | 7 +++++++ 2 files changed, 11 insertions(+) create mode 100644 modules/common/profiles/default.nix diff --git a/modules/common/default.nix b/modules/common/default.nix index d0c90de..292e590 100644 --- a/modules/common/default.nix +++ b/modules/common/default.nix @@ -11,6 +11,10 @@ let allowedTypesString = lib.concatStringSep ", " (builtins.map lib.escapeNixString allowedTypes); in { + imports = [ + ./profiles + ]; + config = { assertions = [ { diff --git a/modules/common/profiles/default.nix b/modules/common/profiles/default.nix new file mode 100644 index 0000000..06511ac --- /dev/null +++ b/modules/common/profiles/default.nix @@ -0,0 +1,7 @@ +# Configuration that spans accross system and home, or are almagations of modules +{ ... }: +{ + imports = [ + # FIXME: empty + ]; +} From 42cbe79cae07a1fa27b289cdadd01a3ac9589c74 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Wed, 3 Jan 2024 16:51:34 +0000 Subject: [PATCH 19/33] common: profiles: migrate bluetooth --- modules/common/profiles/bluetooth/default.nix | 19 +++++++++++++++++++ modules/common/profiles/default.nix | 2 +- modules/nixos/profiles/bluetooth/default.nix | 15 --------------- modules/nixos/profiles/default.nix | 1 - 4 files changed, 20 insertions(+), 17 deletions(-) create mode 100644 modules/common/profiles/bluetooth/default.nix delete mode 100644 modules/nixos/profiles/bluetooth/default.nix diff --git a/modules/common/profiles/bluetooth/default.nix b/modules/common/profiles/bluetooth/default.nix new file mode 100644 index 0000000..bfb8bfc --- /dev/null +++ b/modules/common/profiles/bluetooth/default.nix @@ -0,0 +1,19 @@ +{ config, lib, type, ... }: +let + cfg = config.my.profiles.bluetooth; +in +{ + options.my.profiles.bluetooth = with lib; { + enable = mkEnableOption "bluetooth profile"; + }; + + config = lib.mkIf cfg.enable (lib.mkMerge [ + (lib.optionalAttrs (type == "home") { + my.home.bluetooth.enable = true; + }) + + (lib.optionalAttrs (type == "nixos") { + my.hardware.bluetooth.enable = true; + }) + ]); +} diff --git a/modules/common/profiles/default.nix b/modules/common/profiles/default.nix index 06511ac..a71f3be 100644 --- a/modules/common/profiles/default.nix +++ b/modules/common/profiles/default.nix @@ -2,6 +2,6 @@ { ... }: { imports = [ - # FIXME: empty + ./bluetooth ]; } diff --git a/modules/nixos/profiles/bluetooth/default.nix b/modules/nixos/profiles/bluetooth/default.nix deleted file mode 100644 index 292d0d1..0000000 --- a/modules/nixos/profiles/bluetooth/default.nix +++ /dev/null @@ -1,15 +0,0 @@ -{ config, lib, ... }: -let - cfg = config.my.profiles.bluetooth; -in -{ - options.my.profiles.bluetooth = with lib; { - enable = mkEnableOption "bluetooth profile"; - }; - - config = lib.mkIf cfg.enable { - my.hardware.bluetooth.enable = true; - - my.home.bluetooth.enable = true; - }; -} diff --git a/modules/nixos/profiles/default.nix b/modules/nixos/profiles/default.nix index 43d5a84..c442eec 100644 --- a/modules/nixos/profiles/default.nix +++ b/modules/nixos/profiles/default.nix @@ -2,7 +2,6 @@ { ... }: { imports = [ - ./bluetooth ./devices ./gtk ./laptop From 1d888f68e35037423432610029d12ac0150d8285 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Wed, 3 Jan 2024 17:03:09 +0000 Subject: [PATCH 20/33] common: profiles: migrate devices --- modules/common/default.nix | 4 ++-- modules/common/profiles/default.nix | 1 + modules/common/profiles/devices/default.nix | 22 +++++++++++++++++++++ modules/nixos/profiles/default.nix | 1 - modules/nixos/profiles/devices/default.nix | 20 ------------------- 5 files changed, 25 insertions(+), 23 deletions(-) create mode 100644 modules/common/profiles/devices/default.nix delete mode 100644 modules/nixos/profiles/devices/default.nix diff --git a/modules/common/default.nix b/modules/common/default.nix index 292e590..0a26f45 100644 --- a/modules/common/default.nix +++ b/modules/common/default.nix @@ -3,9 +3,9 @@ { lib, type ? null, ... }: let allowedTypes = [ - "nixos" - "home" "darwin" + "home" + "nixos" ]; allowedTypesString = lib.concatStringSep ", " (builtins.map lib.escapeNixString allowedTypes); diff --git a/modules/common/profiles/default.nix b/modules/common/profiles/default.nix index a71f3be..447e906 100644 --- a/modules/common/profiles/default.nix +++ b/modules/common/profiles/default.nix @@ -3,5 +3,6 @@ { imports = [ ./bluetooth + ./devices ]; } diff --git a/modules/common/profiles/devices/default.nix b/modules/common/profiles/devices/default.nix new file mode 100644 index 0000000..bd16d70 --- /dev/null +++ b/modules/common/profiles/devices/default.nix @@ -0,0 +1,22 @@ +{ config, lib, type, ... }: +let + cfg = config.my.profiles.devices; +in +{ + options.my.profiles.devices = with lib; { + enable = mkEnableOption "devices profile"; + }; + + config = lib.mkIf cfg.enable (lib.mkMerge [ + (lib.optionalAttrs (type == "nixos") { + my.hardware = { + ergodox.enable = true; + + mx-ergo.enable = true; + }; + + # MTP devices auto-mount via file explorers + services.gvfs.enable = true; + }) + ]); +} diff --git a/modules/nixos/profiles/default.nix b/modules/nixos/profiles/default.nix index c442eec..2bcbba2 100644 --- a/modules/nixos/profiles/default.nix +++ b/modules/nixos/profiles/default.nix @@ -2,7 +2,6 @@ { ... }: { imports = [ - ./devices ./gtk ./laptop ./wm diff --git a/modules/nixos/profiles/devices/default.nix b/modules/nixos/profiles/devices/default.nix deleted file mode 100644 index 7dbd299..0000000 --- a/modules/nixos/profiles/devices/default.nix +++ /dev/null @@ -1,20 +0,0 @@ -{ config, lib, ... }: -let - cfg = config.my.profiles.devices; -in -{ - options.my.profiles.devices = with lib; { - enable = mkEnableOption "devices profile"; - }; - - config = lib.mkIf cfg.enable { - my.hardware = { - ergodox.enable = true; - - mx-ergo.enable = true; - }; - - # MTP devices auto-mount via file explorers - services.gvfs.enable = true; - }; -} From 6088f85bec218e3462035d8d730b95c518450eee Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Wed, 3 Jan 2024 17:03:47 +0000 Subject: [PATCH 21/33] common: profiles: migrate gtk --- modules/common/profiles/default.nix | 1 + modules/common/profiles/gtk/default.nix | 21 +++++++++++++++++++++ modules/nixos/profiles/default.nix | 1 - modules/nixos/profiles/gtk/default.nix | 17 ----------------- 4 files changed, 22 insertions(+), 18 deletions(-) create mode 100644 modules/common/profiles/gtk/default.nix delete mode 100644 modules/nixos/profiles/gtk/default.nix diff --git a/modules/common/profiles/default.nix b/modules/common/profiles/default.nix index 447e906..30c1f29 100644 --- a/modules/common/profiles/default.nix +++ b/modules/common/profiles/default.nix @@ -4,5 +4,6 @@ imports = [ ./bluetooth ./devices + ./gtk ]; } diff --git a/modules/common/profiles/gtk/default.nix b/modules/common/profiles/gtk/default.nix new file mode 100644 index 0000000..3fe1309 --- /dev/null +++ b/modules/common/profiles/gtk/default.nix @@ -0,0 +1,21 @@ +{ config, lib, type, ... }: +let + cfg = config.my.profiles.gtk; +in +{ + options.my.profiles.gtk = with lib; { + enable = mkEnableOption "gtk profile"; + }; + + config = lib.mkIf cfg.enable (lib.mkMerge [ + (lib.optionalAttrs (type == "home") { + # GTK theme configuration + my.home.gtk.enable = true; + }) + + (lib.optionalAttrs (type == "nixos") { + # Allow setting GTK configuration using home-manager + programs.dconf.enable = true; + }) + ]); +} diff --git a/modules/nixos/profiles/default.nix b/modules/nixos/profiles/default.nix index 2bcbba2..683bd87 100644 --- a/modules/nixos/profiles/default.nix +++ b/modules/nixos/profiles/default.nix @@ -2,7 +2,6 @@ { ... }: { imports = [ - ./gtk ./laptop ./wm ./x diff --git a/modules/nixos/profiles/gtk/default.nix b/modules/nixos/profiles/gtk/default.nix deleted file mode 100644 index a8d6d9a..0000000 --- a/modules/nixos/profiles/gtk/default.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ config, lib, ... }: -let - cfg = config.my.profiles.gtk; -in -{ - options.my.profiles.gtk = with lib; { - enable = mkEnableOption "gtk profile"; - }; - - config = lib.mkIf cfg.enable { - # Allow setting GTK configuration using home-manager - programs.dconf.enable = true; - - # GTK theme configuration - my.home.gtk.enable = true; - }; -} From 7884ef104743ee324c34734c5ee785f4064622a6 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Wed, 3 Jan 2024 17:05:16 +0000 Subject: [PATCH 22/33] common: profiles: migrate laptop --- modules/common/profiles/default.nix | 1 + modules/common/profiles/laptop/default.nix | 27 ++++++++++++++++++++++ modules/nixos/profiles/default.nix | 1 - modules/nixos/profiles/laptop/default.nix | 23 ------------------ 4 files changed, 28 insertions(+), 24 deletions(-) create mode 100644 modules/common/profiles/laptop/default.nix delete mode 100644 modules/nixos/profiles/laptop/default.nix diff --git a/modules/common/profiles/default.nix b/modules/common/profiles/default.nix index 30c1f29..712e20b 100644 --- a/modules/common/profiles/default.nix +++ b/modules/common/profiles/default.nix @@ -5,5 +5,6 @@ ./bluetooth ./devices ./gtk + ./laptop ]; } diff --git a/modules/common/profiles/laptop/default.nix b/modules/common/profiles/laptop/default.nix new file mode 100644 index 0000000..68e979a --- /dev/null +++ b/modules/common/profiles/laptop/default.nix @@ -0,0 +1,27 @@ +{ config, lib, type, ... }: +let + cfg = config.my.profiles.laptop; +in +{ + options.my.profiles.laptop = with lib; { + enable = mkEnableOption "laptop profile"; + }; + + config = lib.mkIf cfg.enable (lib.mkMerge [ + (lib.optionalAttrs (type == "home") { + # Enable battery notifications + my.home.power-alert.enable = true; + }) + + (lib.optionalAttrs (type == "nixos") { + # Enable touchpad support + services.xserver.libinput.enable = true; + + # Enable TLP power management + my.services.tlp.enable = true; + + # Enable upower power management + my.hardware.upower.enable = true; + }) + ]); +} diff --git a/modules/nixos/profiles/default.nix b/modules/nixos/profiles/default.nix index 683bd87..1951298 100644 --- a/modules/nixos/profiles/default.nix +++ b/modules/nixos/profiles/default.nix @@ -2,7 +2,6 @@ { ... }: { imports = [ - ./laptop ./wm ./x ]; diff --git a/modules/nixos/profiles/laptop/default.nix b/modules/nixos/profiles/laptop/default.nix deleted file mode 100644 index 20a29d7..0000000 --- a/modules/nixos/profiles/laptop/default.nix +++ /dev/null @@ -1,23 +0,0 @@ -{ config, lib, ... }: -let - cfg = config.my.profiles.laptop; -in -{ - options.my.profiles.laptop = with lib; { - enable = mkEnableOption "laptop profile"; - }; - - config = lib.mkIf cfg.enable { - # Enable touchpad support - services.xserver.libinput.enable = true; - - # Enable TLP power management - my.services.tlp.enable = true; - - # Enable upower power management - my.hardware.upower.enable = true; - - # Enable battery notifications - my.home.power-alert.enable = true; - }; -} From e4b7d562a4368590556d1e075fa48d9939346797 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Wed, 3 Jan 2024 17:05:37 +0000 Subject: [PATCH 23/33] common: profiles: migrate wm --- modules/common/profiles/default.nix | 1 + modules/common/profiles/wm/default.nix | 36 ++++++++++++++++++++++++++ modules/nixos/profiles/default.nix | 1 - modules/nixos/profiles/wm/default.nix | 29 --------------------- 4 files changed, 37 insertions(+), 30 deletions(-) create mode 100644 modules/common/profiles/wm/default.nix delete mode 100644 modules/nixos/profiles/wm/default.nix diff --git a/modules/common/profiles/default.nix b/modules/common/profiles/default.nix index 712e20b..034d993 100644 --- a/modules/common/profiles/default.nix +++ b/modules/common/profiles/default.nix @@ -6,5 +6,6 @@ ./devices ./gtk ./laptop + ./wm ]; } diff --git a/modules/common/profiles/wm/default.nix b/modules/common/profiles/wm/default.nix new file mode 100644 index 0000000..4c974e1 --- /dev/null +++ b/modules/common/profiles/wm/default.nix @@ -0,0 +1,36 @@ +{ config, lib, type, ... }: +let + cfg = config.my.profiles.wm; + + applyWm = wm: configs: lib.mkIf (cfg.windowManager == wm) (lib.my.merge configs); +in +{ + options.my.profiles.wm = with lib; { + windowManager = mkOption { + type = with types; nullOr (enum [ "i3" ]); + default = null; + example = "i3"; + description = "Which window manager to use"; + }; + }; + + config = lib.mkMerge [ + (applyWm "i3" [ + (lib.optionalAttrs (type == "home") { + # i3 settings + my.home.wm.windowManager = "i3"; + # Screenshot tool + my.home.flameshot.enable = true; + # Auto disk mounter + my.home.udiskie.enable = true; + }) + + (lib.optionalAttrs (type == "nixos") { + # Enable i3 + services.xserver.windowManager.i3.enable = true; + # udiskie fails if it can't find this dbus service + services.udisks2.enable = true; + }) + ]) + ]; +} diff --git a/modules/nixos/profiles/default.nix b/modules/nixos/profiles/default.nix index 1951298..6b4db55 100644 --- a/modules/nixos/profiles/default.nix +++ b/modules/nixos/profiles/default.nix @@ -2,7 +2,6 @@ { ... }: { imports = [ - ./wm ./x ]; } diff --git a/modules/nixos/profiles/wm/default.nix b/modules/nixos/profiles/wm/default.nix deleted file mode 100644 index c227328..0000000 --- a/modules/nixos/profiles/wm/default.nix +++ /dev/null @@ -1,29 +0,0 @@ -{ config, lib, ... }: -let - cfg = config.my.profiles.wm; -in -{ - options.my.profiles.wm = with lib; { - windowManager = mkOption { - type = with types; nullOr (enum [ "i3" ]); - default = null; - example = "i3"; - description = "Which window manager to use"; - }; - }; - - config = lib.mkMerge [ - (lib.mkIf (cfg.windowManager == "i3") { - # Enable i3 - services.xserver.windowManager.i3.enable = true; - # i3 settings - my.home.wm.windowManager = "i3"; - # Screenshot tool - my.home.flameshot.enable = true; - # Auto disk mounter - my.home.udiskie.enable = true; - # udiskie fails if it can't find this dbus service - services.udisks2.enable = true; - }) - ]; -} From 198b8e7e0a4f4a0592d0194130b4f8fc5c53b098 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Wed, 3 Jan 2024 17:05:54 +0000 Subject: [PATCH 24/33] common: profiles: migrate X --- modules/common/profiles/default.nix | 1 + modules/common/profiles/x/default.nix | 27 +++++++++++++++++++++++++++ modules/nixos/default.nix | 1 - modules/nixos/profiles/default.nix | 7 ------- modules/nixos/profiles/x/default.nix | 23 ----------------------- 5 files changed, 28 insertions(+), 31 deletions(-) create mode 100644 modules/common/profiles/x/default.nix delete mode 100644 modules/nixos/profiles/default.nix delete mode 100644 modules/nixos/profiles/x/default.nix diff --git a/modules/common/profiles/default.nix b/modules/common/profiles/default.nix index 034d993..43d5a84 100644 --- a/modules/common/profiles/default.nix +++ b/modules/common/profiles/default.nix @@ -7,5 +7,6 @@ ./gtk ./laptop ./wm + ./x ]; } diff --git a/modules/common/profiles/x/default.nix b/modules/common/profiles/x/default.nix new file mode 100644 index 0000000..907e03c --- /dev/null +++ b/modules/common/profiles/x/default.nix @@ -0,0 +1,27 @@ +{ config, lib, pkgs, type, ... }: +let + cfg = config.my.profiles.x; +in +{ + options.my.profiles.x = with lib; { + enable = mkEnableOption "X profile"; + }; + + config = lib.mkIf cfg.enable (lib.mkMerge [ + (lib.optionalAttrs (type == "home") { + # X configuration + my.home.x.enable = true; + }) + + (lib.optionalAttrs (type == "nixos") { + # Enable the X11 windowing system. + services.xserver.enable = true; + # Nice wallpaper + services.xserver.displayManager.lightdm.background = + let + wallpapers = "${pkgs.plasma5Packages.plasma-workspace-wallpapers}/share/wallpapers"; + in + "${wallpapers}/summer_1am/contents/images/2560x1600.jpg"; + }) + ]); +} diff --git a/modules/nixos/default.nix b/modules/nixos/default.nix index 3648631..2eaa2e6 100644 --- a/modules/nixos/default.nix +++ b/modules/nixos/default.nix @@ -5,7 +5,6 @@ imports = [ ./hardware ./home - ./profiles ./programs ./secrets ./services diff --git a/modules/nixos/profiles/default.nix b/modules/nixos/profiles/default.nix deleted file mode 100644 index 6b4db55..0000000 --- a/modules/nixos/profiles/default.nix +++ /dev/null @@ -1,7 +0,0 @@ -# Configuration that spans accross system and home, or are almagations of modules -{ ... }: -{ - imports = [ - ./x - ]; -} diff --git a/modules/nixos/profiles/x/default.nix b/modules/nixos/profiles/x/default.nix deleted file mode 100644 index ea77939..0000000 --- a/modules/nixos/profiles/x/default.nix +++ /dev/null @@ -1,23 +0,0 @@ -{ config, lib, pkgs, ... }: -let - cfg = config.my.profiles.x; -in -{ - options.my.profiles.x = with lib; { - enable = mkEnableOption "X profile"; - }; - - config = lib.mkIf cfg.enable { - # Enable the X11 windowing system. - services.xserver.enable = true; - # Nice wallpaper - services.xserver.displayManager.lightdm.background = - let - wallpapers = "${pkgs.plasma5Packages.plasma-workspace-wallpapers}/share/wallpapers"; - in - "${wallpapers}/summer_1am/contents/images/2560x1600.jpg"; - - # X configuration - my.home.x.enable = true; - }; -} From 2d3add3536713477ee184a973a490296544e71bb Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Wed, 3 Jan 2024 16:51:34 +0000 Subject: [PATCH 25/33] nixos: home: forward profile configurations Now that we migrated them all --- modules/nixos/home/default.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/nixos/home/default.nix b/modules/nixos/home/default.nix index 2d323d1..5a8e796 100644 --- a/modules/nixos/home/default.nix +++ b/modules/nixos/home/default.nix @@ -19,6 +19,11 @@ in "${inputs.self}/modules/common"; "${inputs.self}/modules/home"; ]; + + config = { + # Transparently enable home-manager profiles as well + inherit (config.my) profiles; + }; }; # Nix Flakes compatibility From fefd405e086b25d28e0822efa99ecf332b04c978 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Wed, 3 Jan 2024 17:46:19 +0000 Subject: [PATCH 26/33] fixup! nixos: home: import common modules --- modules/nixos/home/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/nixos/home/default.nix b/modules/nixos/home/default.nix index 5a8e796..84e3d8a 100644 --- a/modules/nixos/home/default.nix +++ b/modules/nixos/home/default.nix @@ -16,8 +16,8 @@ in # Not a fan of out-of-directory imports, but this is a good exception users.${config.my.user.name} = { imports = [ - "${inputs.self}/modules/common"; - "${inputs.self}/modules/home"; + "${inputs.self}/modules/common" + "${inputs.self}/modules/home" ]; config = { From 37cfcadfc6a9462efbf11c368b60428092c4ab7f Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Wed, 3 Jan 2024 17:50:47 +0000 Subject: [PATCH 27/33] fixup! nixos: home: forward profile configurations --- modules/nixos/home/default.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/nixos/home/default.nix b/modules/nixos/home/default.nix index 84e3d8a..384692d 100644 --- a/modules/nixos/home/default.nix +++ b/modules/nixos/home/default.nix @@ -21,8 +21,10 @@ in ]; config = { - # Transparently enable home-manager profiles as well - inherit (config.my) profiles; + my = { + # Transparently enable home-manager profiles as well + inherit (config.my) profiles; + }; }; }; From f5e24b5db83044eea63da3ee5197b9b57de51a28 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Wed, 3 Jan 2024 17:55:14 +0000 Subject: [PATCH 28/33] hosts: nixos: porthos: add profiles --- hosts/nixos/porthos/default.nix | 1 + hosts/nixos/porthos/profiles.nix | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 hosts/nixos/porthos/profiles.nix diff --git a/hosts/nixos/porthos/default.nix b/hosts/nixos/porthos/default.nix index 2dea899..39e2998 100644 --- a/hosts/nixos/porthos/default.nix +++ b/hosts/nixos/porthos/default.nix @@ -7,6 +7,7 @@ ./hardware.nix ./home.nix ./networking.nix + ./profiles.nix ./secrets ./services.nix ./system.nix diff --git a/hosts/nixos/porthos/profiles.nix b/hosts/nixos/porthos/profiles.nix new file mode 100644 index 0000000..3ec736c --- /dev/null +++ b/hosts/nixos/porthos/profiles.nix @@ -0,0 +1,4 @@ +{ ... }: +{ + # Nothing +} From 9b68905c26542cd85aaa3a0f62e650e8911759dc Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Thu, 7 Dec 2023 21:31:46 +0000 Subject: [PATCH 29/33] flake: add hosts This will allow other modules to cross-reference which hosts exist on which system. My main use-case is to automatically declare home-manager configuration for the home configuration of NixOS hosts. I also include Darwin in case I ever want to use that in the future, though that is unlikely for the moment. --- flake/default.nix | 1 + flake/hosts.nix | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 flake/hosts.nix diff --git a/flake/default.nix b/flake/default.nix index 65102e1..e4b2e8f 100644 --- a/flake/default.nix +++ b/flake/default.nix @@ -13,6 +13,7 @@ flake-parts.lib.mkFlake { inherit inputs; } { ./checks.nix ./dev-shells.nix ./home-manager.nix + ./hosts.nix ./lib.nix ./nixos.nix ./overlays.nix diff --git a/flake/hosts.nix b/flake/hosts.nix new file mode 100644 index 0000000..7d95fdc --- /dev/null +++ b/flake/hosts.nix @@ -0,0 +1,21 @@ +# Define `hosts.{darwin,home,nixos}` options for consumption in other modules +{ lib, ... }: +let + mkHostsOption = description: lib.mkOption { + inherit description; + type = with lib.types; attrsOf str; + default = { }; + example = { name = "x86_64-linux"; }; + }; +in +{ + options = { + hosts = { + darwin = mkHostsOption "Darwin hosts"; + + homes = mkHostsOption "Home Manager hosts"; + + nixos = mkHostsOption "NixOS hosts"; + }; + }; +} From 437b8b8b1738b7e1831bc42714f41e917b2ad57d Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Thu, 7 Dec 2023 21:33:10 +0000 Subject: [PATCH 30/33] flake: nixos: use 'hosts' option --- flake/nixos.nix | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/flake/nixos.nix b/flake/nixos.nix index c5d9ede..49b7770 100644 --- a/flake/nixos.nix +++ b/flake/nixos.nix @@ -1,4 +1,4 @@ -{ self, inputs, lib, ... }: +{ self, config, inputs, lib, ... }: let defaultModules = [ { @@ -32,8 +32,12 @@ let }; in { - flake.nixosConfigurations = lib.mapAttrs buildHost { - aramis = "x86_64-linux"; - porthos = "x86_64-linux"; + config = { + hosts.nixos = { + aramis = "x86_64-linux"; + porthos = "x86_64-linux"; + }; + + flake.nixosConfigurations = lib.mapAttrs buildHost config.hosts.nixos; }; } From d6e3f20208af9987b11b93128ebcc537a23ba5fb Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Thu, 7 Dec 2023 21:41:05 +0000 Subject: [PATCH 31/33] flake: home-manager: use 'hosts' option --- flake/home-manager.nix | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/flake/home-manager.nix b/flake/home-manager.nix index 2f7e245..7d87a61 100644 --- a/flake/home-manager.nix +++ b/flake/home-manager.nix @@ -1,5 +1,7 @@ -{ self, inputs, lib, ... }: +{ self, config, inputs, lib, ... }: let + inherit (config) hosts; + defaultModules = [ # Include generic settings "${self}/modules/home" @@ -43,18 +45,19 @@ let }; }; - homes = { +in +{ + hosts.homes = { "ambroisie@bazin" = "x86_64-linux"; "ambroisie@mousqueton" = "x86_64-linux"; }; -in -{ + perSystem = { system, ... }: { # Work-around for https://github.com/nix-community/home-manager/issues/3075 legacyPackages = { homeConfigurations = let - filteredHomes = lib.filterAttrs (_: v: v == system) homes; + filteredHomes = lib.filterAttrs (_: v: v == system) hosts.homes; allHomes = filteredHomes // { # Default configuration ambroisie = system; From 7bd06002debfb1071c0a42a4e5f585532b96a00a Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Thu, 7 Dec 2023 21:44:01 +0000 Subject: [PATCH 32/33] flake: home-manager: refactor 'mkHome' This will allow making a similar function for NixOS homes. --- flake/home-manager.nix | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/flake/home-manager.nix b/flake/home-manager.nix index 7d87a61..449fcfd 100644 --- a/flake/home-manager.nix +++ b/flake/home-manager.nix @@ -20,7 +20,7 @@ let "${self}/modules/common" ]; - mkHome = name: system: inputs.home-manager.lib.homeManagerConfiguration { + mkHomeCommon = mainModules: system: inputs.home-manager.lib.homeManagerConfiguration { # Work-around for home-manager # * not letting me set `lib` as an extraSpecialArgs # * not respecting `nixpkgs.overlays` [1] @@ -33,9 +33,7 @@ let ]; }; - modules = defaultModules ++ [ - "${self}/hosts/homes/${name}" - ]; + modules = defaultModules ++ mainModules; extraSpecialArgs = { # Inject inputs to use them in global registry @@ -45,6 +43,7 @@ let }; }; + mkHome = name: mkHomeCommon "${self}/hosts/homes/${name}"; in { hosts.homes = { From 7ebfaa1de814c7e6fc80372188d6aaf366018570 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Thu, 7 Dec 2023 21:56:25 +0000 Subject: [PATCH 33/33] WIP: flake: home-manager: export NixOS homes WIP: this does not take into account the `profiles` which *also* setup home-manager modules... And here is what the last few commits were building up to. This is neat, but won't be useful *very* often. --- flake/home-manager.nix | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/flake/home-manager.nix b/flake/home-manager.nix index 449fcfd..bbbabc0 100644 --- a/flake/home-manager.nix +++ b/flake/home-manager.nix @@ -43,7 +43,12 @@ let }; }; - mkHome = name: mkHomeCommon "${self}/hosts/homes/${name}"; + mkHome = name: mkHomeCommon [ "${self}/hosts/homes/${name}" ]; + + mkNixosHome = name: mkHomeCommon [ + "${self}/hosts/nixos/${name}/home.nix" + "${self}/hosts/nixos/${name}/profiles.nix" + ]; in { hosts.homes = { @@ -61,8 +66,18 @@ in # Default configuration ambroisie = system; }; + homeManagerHomes = lib.mapAttrs mkHome allHomes; + + filteredNixosHosts = lib.filterAttrs (_: v: v == system) hosts.nixos; + nixosHomes' = lib.mapAttrs mkNixosHome filteredNixosHosts; + nixosHomeUsername = (host: self.nixosConfigurations.${host}.config.my.user.name); + nixosHomes = lib.mapAttrs' (host: lib.nameValuePair "${nixosHomeUsername host}@${host}") nixosHomes'; in - lib.mapAttrs mkHome allHomes; + lib.foldl' lib.mergeAttrs { } + [ + homeManagerHomes + nixosHomes + ]; }; }; }