migrate to flake-parts

Changed files
+162 -188
hosts
modules
+41 -37
flake.lock
··· 118 118 "type": "github" 119 119 } 120 120 }, 121 + "flake-parts": { 122 + "inputs": { 123 + "nixpkgs-lib": "nixpkgs-lib" 124 + }, 125 + "locked": { 126 + "lastModified": 1765835352, 127 + "narHash": "sha256-XswHlK/Qtjasvhd1nOa1e8MgZ8GS//jBoTqWtrS1Giw=", 128 + "owner": "hercules-ci", 129 + "repo": "flake-parts", 130 + "rev": "a34fae9c08a15ad73f295041fec82323541400a9", 131 + "type": "github" 132 + }, 133 + "original": { 134 + "owner": "hercules-ci", 135 + "repo": "flake-parts", 136 + "type": "github" 137 + } 138 + }, 121 139 "flake-utils": { 122 140 "inputs": { 123 141 "systems": "systems" ··· 159 177 }, 160 178 "flake-utils_3": { 161 179 "inputs": { 162 - "systems": "systems_4" 180 + "systems": "systems_3" 163 181 }, 164 182 "locked": { 165 183 "lastModified": 1731533236, ··· 417 435 "type": "github" 418 436 } 419 437 }, 438 + "nixpkgs-lib": { 439 + "locked": { 440 + "lastModified": 1765674936, 441 + "narHash": "sha256-k00uTP4JNfmejrCLJOwdObYC9jHRrr/5M/a/8L2EIdo=", 442 + "owner": "nix-community", 443 + "repo": "nixpkgs.lib", 444 + "rev": "2075416fcb47225d9b68ac469a5c4801a9c4dd85", 445 + "type": "github" 446 + }, 447 + "original": { 448 + "owner": "nix-community", 449 + "repo": "nixpkgs.lib", 450 + "type": "github" 451 + } 452 + }, 420 453 "nixpkgs-stable": { 421 454 "locked": { 422 455 "lastModified": 1766736597, ··· 448 481 }, 449 482 "nixpkgs_3": { 450 483 "locked": { 451 - "lastModified": 1759381078, 452 - "narHash": "sha256-gTrEEp5gEspIcCOx9PD8kMaF1iEmfBcTbO0Jag2QhQs=", 484 + "lastModified": 1766902085, 485 + "narHash": "sha256-coBu0ONtFzlwwVBzmjacUQwj3G+lybcZ1oeNSQkgC0M=", 453 486 "owner": "nixos", 454 487 "repo": "nixpkgs", 455 - "rev": "7df7ff7d8e00218376575f0acdcc5d66741351ee", 488 + "rev": "c0b0e0fddf73fd517c3471e546c0df87a42d53f4", 456 489 "type": "github" 457 490 }, 458 491 "original": { ··· 526 559 "type": "github" 527 560 } 528 561 }, 529 - "nixpkgs_8": { 530 - "locked": { 531 - "lastModified": 1765934234, 532 - "narHash": "sha256-pJjWUzNnjbIAMIc5gRFUuKCDQ9S1cuh3b2hKgA7Mc4A=", 533 - "owner": "NixOS", 534 - "repo": "nixpkgs", 535 - "rev": "af84f9d270d404c17699522fab95bbf928a2d92f", 536 - "type": "github" 537 - }, 538 - "original": { 539 - "owner": "NixOS", 540 - "ref": "nixpkgs-unstable", 541 - "repo": "nixpkgs", 542 - "type": "github" 543 - } 544 - }, 545 562 "pre-commit": { 546 563 "inputs": { 547 564 "flake-compat": "flake-compat_2", ··· 568 585 "root": { 569 586 "inputs": { 570 587 "catppuccin": "catppuccin", 588 + "flake-parts": "flake-parts", 571 589 "ghostty": "ghostty", 572 590 "helix": "helix", 573 591 "home-manager": "home-manager_2", ··· 579 597 "sops-nix": "sops-nix", 580 598 "ssh-keys": "ssh-keys", 581 599 "starship-jj": "starship-jj", 582 - "systems": "systems_3", 583 600 "topiary-nushell": "topiary-nushell", 584 601 "tree-sitter-nu": "tree-sitter-nu", 585 602 "zjstatus": "zjstatus" ··· 763 780 "type": "github" 764 781 } 765 782 }, 766 - "systems_4": { 767 - "locked": { 768 - "lastModified": 1681028828, 769 - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", 770 - "owner": "nix-systems", 771 - "repo": "default", 772 - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", 773 - "type": "github" 774 - }, 775 - "original": { 776 - "owner": "nix-systems", 777 - "repo": "default", 778 - "type": "github" 779 - } 780 - }, 781 783 "topiary-nushell": { 782 784 "flake": false, 783 785 "locked": { ··· 876 878 "inputs": { 877 879 "crane": "crane_2", 878 880 "flake-utils": "flake-utils_3", 879 - "nixpkgs": "nixpkgs_8", 881 + "nixpkgs": [ 882 + "nixpkgs" 883 + ], 880 884 "rust-overlay": "rust-overlay_3" 881 885 }, 882 886 "locked": {
+53 -83
flake.nix
··· 6 6 inputs.nixpkgs.follows = "nixpkgs"; 7 7 }; 8 8 nixos-wsl.url = "github:nix-community/NixOS-WSL/main"; 9 - systems.url = "github:nix-systems/default"; 10 9 catppuccin = { 11 10 url = "github:catppuccin/nix"; 12 11 }; ··· 26 25 url = "https://github.com/karitham.keys"; 27 26 flake = false; 28 27 }; 29 - 30 28 zjstatus = { 31 29 url = "github:dj95/zjstatus"; 30 + inputs.nixpkgs.follows = "nixpkgs"; 32 31 }; 33 32 knixpkgs = { 34 33 url = "github:karitham/knixpkgs"; 35 - inputs.nixpkgs.follows = "nixpkgs"; # use the same mesa as local system 34 + inputs.nixpkgs.follows = "nixpkgs"; 36 35 }; 37 - 38 36 tree-sitter-nu = { 39 37 url = "github:nushell/tree-sitter-nu"; 40 38 flake = false; 41 39 }; 42 - 43 40 topiary-nushell = { 44 41 url = "github:blindFS/topiary-nushell"; 45 42 flake = false; 46 43 }; 47 - 48 44 sops-nix = { 49 45 url = "github:Mic92/sops-nix"; 50 46 inputs.nixpkgs.follows = "nixpkgs"; 51 47 }; 48 + flake-parts.url = "github:hercules-ci/flake-parts"; 52 49 }; 53 - outputs = inputs @ { 50 + outputs = { 54 51 self, 55 52 nixpkgs, 53 + flake-parts, 56 54 ... 57 - }: let 58 - hasHome = cfg: (cfg ? home) && cfg.home; 55 + } @ inputs: 56 + flake-parts.lib.mkFlake {inherit inputs;} ( 57 + {withSystem, ...}: { 58 + systems = [ 59 + "x86_64-linux" 60 + "aarch64-linux" 61 + ]; 59 62 60 - # Unified system configuration 61 - systems = { 62 - belaf = { 63 - user = "kar"; 64 - home = true; 65 - arch = "x86_64-linux"; 66 - }; 67 - kiwi = { 68 - user = "kar"; 69 - home = true; 70 - arch = "x86_64-linux"; 71 - }; 72 - reg = { 73 - user = "root"; 74 - arch = "x86_64-linux"; 75 - }; 76 - ozen = { 77 - user = "nixos"; 78 - home = true; 79 - arch = "x86_64-linux"; 80 - }; 81 - wakuna = { 82 - user = "root"; 83 - arch = "aarch64-linux"; 84 - }; 85 - }; 63 + perSystem = {pkgs, ...}: { 64 + packages = { 65 + pokego = pkgs.callPackage ./pkgs/pokego.nix {}; 66 + http-nu = pkgs.callPackage ./pkgs/http-nu.nix {}; 67 + topiary-nu = pkgs.callPackage ./pkgs/topiary-nu.nix { 68 + inherit (inputs) tree-sitter-nu topiary-nushell; 69 + }; 86 70 87 - # Helper function to create NixOS configurations 88 - mkSystem = hostname: cfg: 89 - nixpkgs.lib.nixosSystem { 90 - specialArgs = let 91 - inherit (nixpkgs) lib; 92 - in { 93 - inherit inputs; 94 - username = cfg.user; 95 - inputs' = lib.mapAttrs (_: lib.mapAttrs (_: v: v.${cfg.arch} or v)) inputs; 71 + wakuna-image = self.lib.sdImageFromSystem self.nixosConfigurations.wakuna; 72 + }; 73 + formatter = pkgs.alejandra; 96 74 }; 97 - modules = 98 - [ 99 - (_: { 100 - networking.hostName = hostname; 101 - nix.registry = { 102 - self.flake = self; 103 - }; 104 - }) 105 - ./modules/nixos 106 - ./hosts/${hostname} 107 - ] 108 - ++ nixpkgs.lib.optionals (hasHome cfg) [ 109 - inputs.home-manager.nixosModules.home-manager 110 - inputs.niri.nixosModules.niri 111 - ./modules/home 112 - ]; 113 - }; 114 75 115 - forAllSystems = function: 116 - nixpkgs.lib.genAttrs (import inputs.systems) (system: function nixpkgs.legacyPackages.${system}); 117 - in { 118 - nixosConfigurations = nixpkgs.lib.mapAttrs mkSystem systems; 76 + flake = let 77 + inherit (nixpkgs) lib; 78 + in { 79 + lib = { 80 + sdImageFromSystem = system: system.config.system.build.sdImage; 119 81 120 - homeConfigurations = nixpkgs.lib.mapAttrs' (hostname: cfg: { 121 - name = "${cfg.user}@${hostname}"; 122 - value = { 123 - config = self.nixosConfigurations.${hostname}.config.home-manager.users.${cfg.user}; 124 - }; 125 - }) (nixpkgs.lib.filterAttrs (_: hasHome) systems); 82 + mkSystem' = system: hostname: 83 + withSystem system ({ 84 + inputs', 85 + self', 86 + ... 87 + }: 88 + lib.nixosSystem { 89 + specialArgs = {inherit inputs inputs' self self';}; 90 + modules = [ 91 + {networking.hostName = hostname;} 92 + ./modules/core.nix 93 + ./modules/nixos 94 + ./hosts/${hostname} 95 + ]; 96 + }); 126 97 127 - images = { 128 - wakuna = self.nixosConfigurations.wakuna.config.system.build.sdImage; 129 - }; 98 + mkSystem = system: hostname: {${hostname} = self.lib.mkSystem' system hostname;}; 99 + mkSystems = system: hosts: lib.mergeAttrsList (map (self.lib.mkSystem system) hosts); 100 + }; 130 101 131 - packages = forAllSystems (pkgs: { 132 - pokego = pkgs.callPackage ./pkgs/pokego.nix {}; 133 - http-nu = pkgs.callPackage ./pkgs/http-nu.nix {}; 134 - topiary-nu = pkgs.callPackage ./pkgs/topiary-nu.nix { 135 - inherit (inputs) tree-sitter-nu topiary-nushell; 136 - }; 137 - }); 102 + nixosConfigurations = inputs.nixpkgs.lib.concatMapAttrs self.lib.mkSystems { 103 + "x86_64-linux" = ["ozen" "kiwi" "reg" "belaf"]; 104 + "aarch64-linux" = ["wakuna"]; 105 + }; 138 106 139 - overlays.default = import ./overlays; 140 - }; 107 + overlays.default = import ./overlays; 108 + }; 109 + } 110 + ); 141 111 nixConfig = { 142 112 warn-dirty = false; 143 113 extra-experimental-features = [
+12 -13
hosts/belaf/default.nix
··· 4 4 inputs, 5 5 ... 6 6 }: { 7 - catppuccin.enable = true; 8 - catppuccin.flavor = "macchiato"; 9 - desktop.niri = true; 7 + imports = [ 8 + inputs.lanzaboote.nixosModules.lanzaboote 9 + inputs.catppuccin.nixosModules.catppuccin 10 + ../../modules/home 11 + ./hardware.nix 12 + ]; 13 + catppuccin = { 14 + enable = true; 15 + flavor = "macchiato"; 16 + }; 10 17 time.timeZone = "Europe/Paris"; 11 - 12 - system = { 13 - stateVersion = "25.11"; 14 - }; 18 + desktop.enable = true; 19 + system.stateVersion = "25.11"; 15 20 16 21 boot = { 17 22 loader.systemd-boot = { ··· 57 62 data-root = "/docker"; 58 63 }; 59 64 }; 60 - 61 - imports = [ 62 - inputs.lanzaboote.nixosModules.lanzaboote 63 - inputs.catppuccin.nixosModules.catppuccin 64 - ./hardware.nix 65 - ]; 66 65 }
+9 -13
hosts/kiwi/default.nix
··· 1 1 { 2 2 inputs, 3 - inputs', 4 3 pkgs, 5 4 ... 6 5 }: { 6 + imports = [ 7 + inputs.catppuccin.nixosModules.catppuccin 8 + ../../modules/home 9 + ./hardware.nix 10 + ]; 11 + 12 + yubikey.enable = true; 7 13 catppuccin = { 8 14 enable = true; 9 15 flavor = "macchiato"; 10 16 }; 11 - desktop.niri = true; 12 - ipcam.enable = false; 13 - yubikey.enable = true; 14 17 time.timeZone = "Europe/Paris"; 15 - 16 - system = { 17 - stateVersion = "25.05"; 18 - }; 19 - 20 - imports = [ 21 - inputs.catppuccin.nixosModules.catppuccin 22 - ./hardware.nix 23 - ]; 18 + desktop.enable = true; 19 + system.stateVersion = "25.11"; 24 20 25 21 home-manager.users.kar.imports = [ 26 22 ./home-upf.nix
+8 -9
hosts/ozen/default.nix
··· 2 2 inputs, 3 3 pkgs, 4 4 lib, 5 - username, 5 + config, 6 6 ... 7 7 }: let 8 8 inherit (lib) mkForce; 9 9 in { 10 + my.username = "nixos"; 11 + 10 12 imports = [ 11 13 inputs.catppuccin.nixosModules.catppuccin 12 14 inputs.nixos-wsl.nixosModules.default 13 - { 14 - system.stateVersion = "24.11"; 15 - wsl.enable = true; 16 - wsl.defaultUser = "nixos"; 17 - } 15 + ../../modules/home 18 16 ]; 19 17 20 18 catppuccin = { 21 19 enable = true; 22 20 flavor = "macchiato"; 23 21 }; 22 + wsl.enable = true; 23 + wsl.defaultUser = config.my.username; 24 + system.stateVersion = "25.11"; 24 25 25 26 virtualisation.docker.enable = true; 26 27 27 - programs = { 28 - ssh.startAgent = true; 29 - }; 28 + programs.ssh.startAgent = true; 30 29 31 30 services = { 32 31 smartd.enable = mkForce false;
+4 -2
hosts/reg/default.nix
··· 1 1 { 2 + config, 2 3 pkgs, 3 4 inputs, 4 - username, 5 5 ... 6 6 }: { 7 + my.username = "root"; 8 + 7 9 imports = [ 8 10 inputs.sops-nix.nixosModules.sops 9 11 ./hardware.nix ··· 26 28 }; 27 29 28 30 users.users = { 29 - ${username}.openssh.authorizedKeys.keyFiles = [inputs.ssh-keys]; 31 + ${config.my.username}.openssh.authorizedKeys.keyFiles = [inputs.ssh-keys]; 30 32 }; 31 33 32 34 environment.systemPackages = with pkgs; [helix];
+1
hosts/wakuna/default.nix
··· 10 10 ]; 11 11 12 12 sdImage.compressImage = false; 13 + 13 14 nixpkgs.hostPlatform = "aarch64-linux"; 14 15 system.stateVersion = "24.11"; 15 16
+7
modules/core.nix
··· 1 + {lib, ...}: { 2 + options.my.username = lib.mkOption { 3 + type = lib.types.str; 4 + description = "The username for the current user."; 5 + default = "kar"; 6 + }; 7 + }
+9 -7
modules/home/default.nix
··· 2 2 config, 3 3 inputs, 4 4 inputs', 5 - username, 5 + self, 6 + self', 6 7 ... 7 8 }: { 8 - users.users.${username} = 9 - if username != "root" 9 + imports = [inputs.home-manager.nixosModules.default]; 10 + users.users.${config.my.username} = 11 + if config.my.username != "root" 10 12 then { 11 - home = "/home/${username}"; 13 + home = "/home/${config.my.username}"; 12 14 isNormalUser = true; 13 15 extraGroups = [ 14 16 "networkmanager" ··· 19 21 else {}; 20 22 21 23 home-manager = { 22 - extraSpecialArgs = {inherit inputs inputs' username;}; 24 + extraSpecialArgs = {inherit inputs inputs' self self';}; 23 25 backupFileExtension = "bak"; 24 - users.${username} = { 25 - home.username = username; 26 + users.${config.my.username} = { 27 + home.username = config.my.username; 26 28 home.stateVersion = "25.11"; 27 29 28 30 catppuccin = {
+1 -1
modules/home/desktop/niri.nix
··· 5 5 pkgs, 6 6 ... 7 7 }: { 8 - config = lib.mkIf (osConfig.desktop.enable && osConfig.desktop.niri) { 8 + config = lib.mkIf (osConfig.desktop.enable && osConfig.desktop.enable) { 9 9 home.packages = [pkgs.nautilus]; # xdg-desktop-portal-gnome wants it 10 10 programs.niri = { 11 11 settings = {
+1 -1
modules/home/desktop/waybar.nix
··· 21 21 "backlight" 22 22 ]; 23 23 24 - modules-center = lib.optional osConfig.desktop.niri "niri/workspaces"; 24 + modules-center = lib.optional osConfig.desktop.enable "niri/workspaces"; 25 25 26 26 modules-right = [ 27 27 "pulseaudio"
+2 -1
modules/home/dev/helix.nix
··· 2 2 lib, 3 3 pkgs, 4 4 inputs', 5 + self', 5 6 ... 6 7 }: let 7 8 jj-patch = pkgs.fetchurl { ··· 502 503 name = "nu"; 503 504 language-servers = ["nu-lsp"]; 504 505 formatter = { 505 - command = "${lib.getExe inputs'.self.packages.topiary-nu}"; 506 + command = "${lib.getExe self'.packages.topiary-nu}"; 506 507 args = [ 507 508 "format" 508 509 "--language"
+10 -16
modules/nixos/desktop.nix
··· 2 2 config, 3 3 lib, 4 4 pkgs, 5 + inputs, 5 6 ... 6 7 }: let 7 8 cfg = config.desktop; 8 9 in { 9 - options.desktop = let 10 - defaultWallpaper = pkgs.fetchurl { 11 - url = "https://raw.githubusercontent.com/HoulFloof/wallpapers/f23c1010b93cb97baa7ad7c94fd552f7601496d2/misc/waves_right_colored.png"; 12 - hash = "sha256-NqqE+pGnCIWAitH86sxu1EudVEEaSO82y3NqbhtDh9k="; 13 - }; 14 - in { 15 - enable = 16 - lib.mkEnableOption "desktop usage" 17 - // { 18 - default = lib.lists.any (isTrue: isTrue) [ 19 - cfg.niri 20 - ]; 21 - }; 10 + options.desktop = { 11 + enable = lib.mkEnableOption "desktop usage"; 22 12 wallpaper = lib.mkOption { 23 - default = "${defaultWallpaper}"; 13 + default = pkgs.fetchurl { 14 + url = "https://raw.githubusercontent.com/HoulFloof/wallpapers/f23c1010b93cb97baa7ad7c94fd552f7601496d2/misc/waves_right_colored.png"; 15 + hash = "sha256-NqqE+pGnCIWAitH86sxu1EudVEEaSO82y3NqbhtDh9k="; 16 + }; 24 17 type = lib.types.path; 25 18 description = "the wallpaper to use"; 26 19 }; 27 - niri = lib.mkEnableOption "enable niri"; 28 20 }; 21 + 22 + imports = [inputs.niri.nixosModules.niri]; 29 23 30 24 config = lib.mkIf cfg.enable { 31 25 hardware = { ··· 60 54 }; 61 55 62 56 programs = { 63 - niri = lib.mkIf cfg.niri { 57 + niri = { 64 58 enable = true; 65 59 }; 66 60
+2 -2
modules/nixos/nix.nix
··· 1 1 { 2 2 inputs, 3 - username, 4 3 lib, 5 4 config, 6 5 pkgs, ··· 11 10 package = pkgs.lix; 12 11 13 12 registry.nixpkgs.flake = inputs.nixpkgs; 13 + registry.self.flake = inputs.self; 14 14 channel.enable = false; 15 15 16 16 settings = { ··· 50 50 51 51 programs.nh = { 52 52 enable = true; 53 - flake = "/home/${username}/dotfiles"; 53 + flake = "/home/${config.my.username}/dotfiles"; 54 54 }; 55 55 }; 56 56 }
+2 -3
modules/nixos/shell.nix
··· 1 1 { 2 2 config, 3 3 lib, 4 - username, 5 4 pkgs, 6 5 ... 7 6 }: { ··· 9 8 users.defaultUserShell = pkgs.nushell; 10 9 environment.shells = [pkgs.nushell]; 11 10 12 - environment.sessionVariables.EDITOR = lib.attrByPath ["home-manager" "users" username "home" "sessionVariables" "EDITOR"] "nano" config; 13 - programs.nano.enable = !(lib.attrByPath ["home-manager" "users" username "programs" "helix" "enable"] false config); 11 + environment.sessionVariables.EDITOR = lib.attrByPath ["home-manager" "users" config.my.username "home" "sessionVariables" "EDITOR"] "nano" config; 12 + programs.nano.enable = !(lib.attrByPath ["home-manager" "users" config.my.username "programs" "helix" "enable"] false config); 14 13 }; 15 14 }