feat: Added stuff as a attr instead of list

This commit is contained in:
uttarayan21
2025-06-19 18:18:50 +05:30
parent cdc60fefb4
commit c15d06781b
7 changed files with 251 additions and 115 deletions

View File

@@ -5,29 +5,28 @@
home-manager, home-manager,
nix-darwin, nix-darwin,
... ...
}: }: (builtins.mapAttrs (
builtins.listToAttrs (builtins.map (device: { name: device:
name = device.name; nix-darwin.lib.darwinSystem {
value = nix-darwin.lib.darwinSystem { system = device.system;
system = device.system; modules = [
modules = [ {nixpkgs.overlays = overlays;}
{nixpkgs.overlays = overlays;} ./${device.name}/configuration.nix
./${device.name}/configuration.nix home-manager.darwinModules.home-manager
home-manager.darwinModules.home-manager {
{ nixpkgs.config.allowUnfree = true;
nixpkgs.config.allowUnfree = true; home-manager = {
home-manager = { backupFileExtension = "bak";
backupFileExtension = "bak"; useGlobalPkgs = true;
useGlobalPkgs = true; useUserPackages = true;
useUserPackages = true; extraSpecialArgs = {
extraSpecialArgs = { inherit inputs;
inherit inputs; inherit device;
inherit device; };
users.${device.user}.imports = [../home];
}; };
users.${device.user}.imports = [../home]; }
}; ];
} }
]; )
};
})
devices) devices)

120
flake.lock generated
View File

@@ -207,6 +207,22 @@
"type": "github" "type": "github"
} }
}, },
"argononed": {
"flake": false,
"locked": {
"lastModified": 1729566243,
"narHash": "sha256-DPNI0Dpk5aym3Baf5UbEe5GENDrSmmXVdriRSWE+rgk=",
"owner": "nvmd",
"repo": "argononed",
"rev": "16dbee54d49b66d5654d228d1061246b440ef7cf",
"type": "github"
},
"original": {
"owner": "nvmd",
"repo": "argononed",
"type": "github"
}
},
"arion": { "arion": {
"inputs": { "inputs": {
"flake-parts": "flake-parts_3", "flake-parts": "flake-parts_3",
@@ -1833,6 +1849,53 @@
"type": "github" "type": "github"
} }
}, },
"nixos-images": {
"inputs": {
"nixos-stable": [
"nixos-rpi",
"nixpkgs"
],
"nixos-unstable": [
"nixos-rpi",
"nixpkgs"
]
},
"locked": {
"lastModified": 1747747741,
"narHash": "sha256-LUOH27unNWbGTvZFitHonraNx0JF/55h30r9WxqrznM=",
"owner": "nvmd",
"repo": "nixos-images",
"rev": "cbbd6db325775096680b65e2a32fb6187c09bbb4",
"type": "github"
},
"original": {
"owner": "nvmd",
"ref": "sdimage-installer",
"repo": "nixos-images",
"type": "github"
}
},
"nixos-rpi": {
"inputs": {
"argononed": "argononed",
"nixos-images": "nixos-images",
"nixpkgs": "nixpkgs_5"
},
"locked": {
"lastModified": 1749156319,
"narHash": "sha256-Eilhss+fV1Fp88Sua5LwPnxGJ2A1/3TEDI1cMQja/+w=",
"owner": "nvmd",
"repo": "nixos-raspberrypi",
"rev": "dc5ff85af8a5c1e0913bfdc15e419ae430fd0df2",
"type": "github"
},
"original": {
"owner": "nvmd",
"ref": "main",
"repo": "nixos-raspberrypi",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1706487304, "lastModified": 1706487304,
@@ -1945,6 +2008,22 @@
} }
}, },
"nixpkgs_5": { "nixpkgs_5": {
"locked": {
"lastModified": 1748882666,
"narHash": "sha256-z2uanxifOXGEqdiprquIGZu0XaRYih3FHXDQwLc1xis=",
"owner": "nvmd",
"repo": "nixpkgs",
"rev": "d2e9e5abf6308b83487d26e383799f7520dc5cdf",
"type": "github"
},
"original": {
"owner": "nvmd",
"ref": "modules-with-keys-25.05",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_6": {
"locked": { "locked": {
"lastModified": 1749794982, "lastModified": 1749794982,
"narHash": "sha256-Kh9K4taXbVuaLC0IL+9HcfvxsSUx8dPB5s5weJcc9pc=", "narHash": "sha256-Kh9K4taXbVuaLC0IL+9HcfvxsSUx8dPB5s5weJcc9pc=",
@@ -1960,22 +2039,6 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs_6": {
"locked": {
"lastModified": 1644486793,
"narHash": "sha256-EeijR4guVHgVv+JpOX3cQO+1XdrkJfGmiJ9XVsVU530=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "1882c6b7368fd284ad01b0a5b5601ef136321292",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_7": { "nixpkgs_7": {
"locked": { "locked": {
"lastModified": 1644486793, "lastModified": 1644486793,
@@ -1993,6 +2056,22 @@
} }
}, },
"nixpkgs_8": { "nixpkgs_8": {
"locked": {
"lastModified": 1644486793,
"narHash": "sha256-EeijR4guVHgVv+JpOX3cQO+1XdrkJfGmiJ9XVsVU530=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "1882c6b7368fd284ad01b0a5b5601ef136321292",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_9": {
"locked": { "locked": {
"lastModified": 1749794982, "lastModified": 1749794982,
"narHash": "sha256-Kh9K4taXbVuaLC0IL+9HcfvxsSUx8dPB5s5weJcc9pc=", "narHash": "sha256-Kh9K4taXbVuaLC0IL+9HcfvxsSUx8dPB5s5weJcc9pc=",
@@ -2060,7 +2139,7 @@
"inputs": { "inputs": {
"flake-compat": "flake-compat_7", "flake-compat": "flake-compat_7",
"flake-utils": "flake-utils_10", "flake-utils": "flake-utils_10",
"nixpkgs": "nixpkgs_6" "nixpkgs": "nixpkgs_7"
}, },
"locked": { "locked": {
"lastModified": 1672582520, "lastModified": 1672582520,
@@ -2081,7 +2160,7 @@
"inputs": { "inputs": {
"flake-compat": "flake-compat_8", "flake-compat": "flake-compat_8",
"flake-utils": "flake-utils_11", "flake-utils": "flake-utils_11",
"nixpkgs": "nixpkgs_7" "nixpkgs": "nixpkgs_8"
}, },
"locked": { "locked": {
"lastModified": 1713028366, "lastModified": 1713028366,
@@ -2100,7 +2179,7 @@
"nur": { "nur": {
"inputs": { "inputs": {
"flake-parts": "flake-parts_6", "flake-parts": "flake-parts_6",
"nixpkgs": "nixpkgs_8", "nixpkgs": "nixpkgs_9",
"treefmt-nix": "treefmt-nix" "treefmt-nix": "treefmt-nix"
}, },
"locked": { "locked": {
@@ -2284,7 +2363,8 @@
"neogit": "neogit", "neogit": "neogit",
"nix-darwin": "nix-darwin", "nix-darwin": "nix-darwin",
"nix-index-database": "nix-index-database", "nix-index-database": "nix-index-database",
"nixpkgs": "nixpkgs_5", "nixos-rpi": "nixos-rpi",
"nixpkgs": "nixpkgs_6",
"nixpkgs-master": "nixpkgs-master", "nixpkgs-master": "nixpkgs-master",
"nixpkgs-stable": "nixpkgs-stable", "nixpkgs-stable": "nixpkgs-stable",
"nixvim": "nixvim", "nixvim": "nixvim",

View File

@@ -167,6 +167,9 @@
# url = "git+file:/home/servius/Projects/ALVR"; # url = "git+file:/home/servius/Projects/ALVR";
# inputs.nixpkgs.follows = "nixpkgs"; # inputs.nixpkgs.follows = "nixpkgs";
# }; # };
nixos-rpi = {
url = "github:nvmd/nixos-raspberrypi/main";
};
}; };
outputs = { outputs = {
@@ -178,18 +181,19 @@
anyrun, anyrun,
nur, nur,
deploy-rs, deploy-rs,
nixos-rpi,
... ...
} @ inputs: let } @ inputs: let
config_devices = [ devices = {
{ mirai = mkDevice {
name = "mirai"; name = "mirai";
system = "x86_64-linux"; system = "x86_64-linux";
user = "fs0c131y"; user = "fs0c131y";
hasGui = false; # Don't wan't to run GUI apps on a headless server hasGui = false; # Don't wan't to run GUI apps on a headless server
isNix = true; isNix = true;
isServer = true; isServer = true;
} };
{ ryu = mkDevice {
name = "ryu"; name = "ryu";
system = "x86_64-linux"; system = "x86_64-linux";
user = "servius"; user = "servius";
@@ -202,36 +206,44 @@
# Gigabyte M27Q # Gigabyte M27Q
tertiary = "DP-1"; tertiary = "DP-1";
}; };
} };
{ deoxys = mkDevice {
name = "deoxys"; name = "deoxys";
system = "x86_64-linux"; system = "x86_64-linux";
user = "servius"; user = "servius";
hasGui = false; # It's a vm so no GUI apps are used hasGui = false; # It's a vm so no GUI apps are used
isNix = true; isNix = true;
isServer = true; isServer = true;
} };
{ rpi = mkDevice {
name = "rpi";
system = "aarch64-linux";
user = "servius";
hasGui = false;
isNix = true;
isServer = true;
};
kuro = mkDevice {
name = "kuro"; name = "kuro";
system = "aarch64-darwin"; system = "aarch64-darwin";
user = "fs0c131y"; user = "fs0c131y";
} };
{ shiro = mkDevice {
name = "shiro"; name = "shiro";
system = "aarch64-darwin"; system = "aarch64-darwin";
user = "servius"; user = "servius";
isServer = false; isServer = false;
} };
{ deck = mkDevice {
name = "SteamDeck"; name = "SteamDeck";
system = "x86_64-linux"; system = "x86_64-linux";
user = "deck"; user = "deck";
hasGui = false; # Don't wan't to run GUI apps on the SteamDeck hasGui = false; # Don't wan't to run GUI apps on the SteamDeck
isServer = true; isServer = true;
} };
]; };
mkDevice = {device}: { mkDevice = device: {
isLinux = !isNull (builtins.match ".*-linux" device.system); isLinux = !isNull (builtins.match ".*-linux" device.system);
isServer = isServer =
if (builtins.hasAttr "isServer" device) if (builtins.hasAttr "isServer" device)
@@ -255,24 +267,27 @@
user = device.user; user = device.user;
}; };
devices = nixos_devices = nixpkgs.lib.attrsets.filterAttrs (n: x: x.isNix) devices;
builtins.map (device: mkDevice {inherit device;}) config_devices; linux_devices = nixpkgs.lib.attrsets.filterAttrs (n: x: x.isLinux) devices;
darwin_devices = nixpkgs.lib.attrsets.filterAttrs (n: x: x.isDarwin) devices;
nixos_devices = builtins.filter (x: x.isNix) devices; rpi_devices = nixpkgs.lib.attrsets.filterAttrs (n: x: n == "rpi") devices;
linux_devices = builtins.filter (x: x.isLinux) devices;
darwin_devices = builtins.filter (x: x.isDarwin) devices;
overlays = import ./overlays.nix { overlays = import ./overlays.nix {
inherit inputs; inherit inputs;
}; };
in in
rec { rec {
nixosConfigurations = let nixosConfigurations =
devices = nixos_devices; (import ./nixos {
in inherit inputs nixpkgs home-manager overlays nur;
import ./nixos { devices = nixos_devices;
inherit devices inputs nixpkgs home-manager overlays nur; })
}; // (
import ./rpi {
inherit inputs nixpkgs home-manager overlays nur nixos-rpi;
devices = rpi_devices;
}
);
darwinConfigurations = let darwinConfigurations = let
devices = darwin_devices; devices = darwin_devices;

View File

@@ -4,10 +4,8 @@
overlays, overlays,
home-manager, home-manager,
... ...
}: }: (builtins.mapAttrs (
builtins.listToAttrs (builtins.map (device: { name: device: let
name = device.name;
value = let
pkgs = import inputs.nixpkgs { pkgs = import inputs.nixpkgs {
inherit overlays; inherit overlays;
system = device.system; system = device.system;
@@ -20,6 +18,6 @@ builtins.listToAttrs (builtins.map (device: {
inherit device; inherit device;
}; };
modules = [{nixpkgs.config.allowUnfree = true;} ../common/home.nix]; modules = [{nixpkgs.config.allowUnfree = true;} ../common/home.nix];
}; }
}) )
devices) devices)

View File

@@ -6,41 +6,40 @@
home-manager, home-manager,
nur, nur,
... ...
}: }: (builtins.mapAttrs (
builtins.listToAttrs (builtins.map (device: { name: device:
name = device.name; nixpkgs.lib.nixosSystem {
value = nixpkgs.lib.nixosSystem { system = device.system;
system = device.system; specialArgs = {
specialArgs = { inherit device;
inherit device; stablePkgs = inputs.nixpkgs-stable.legacyPackages.${device.system};
stablePkgs = inputs.nixpkgs-stable.legacyPackages.${device.system}; lanzaboote = inputs.lanzaboote;
lanzaboote = inputs.lanzaboote; };
}; modules = [
modules = [ nur.modules.nixos.default
nur.modules.nixos.default inputs.sops-nix.nixosModules.sops
inputs.sops-nix.nixosModules.sops inputs.disko.nixosModules.disko
inputs.disko.nixosModules.disko {nixpkgs.overlays = overlays;}
{nixpkgs.overlays = overlays;} ./${device.name}/configuration.nix
./${device.name}/configuration.nix home-manager.nixosModules.home-manager
home-manager.nixosModules.home-manager inputs.lanzaboote.nixosModules.lanzaboote
inputs.lanzaboote.nixosModules.lanzaboote inputs.musnix.nixosModules.musnix
inputs.musnix.nixosModules.musnix inputs.arion.nixosModules.arion
inputs.arion.nixosModules.arion {
{ nixpkgs.config.allowUnfree = true;
nixpkgs.config.allowUnfree = true; home-manager = {
home-manager = { backupFileExtension = "bak";
backupFileExtension = "bak"; useGlobalPkgs = true;
useGlobalPkgs = true; useUserPackages = true;
useUserPackages = true; extraSpecialArgs = {
extraSpecialArgs = { inherit inputs;
inherit inputs; inherit device;
inherit device; stablePkgs = inputs.nixpkgs-stable.legacyPackages.${device.system};
stablePkgs = inputs.nixpkgs-stable.legacyPackages.${device.system}; };
users.${device.user}.imports = [../home];
}; };
users.${device.user}.imports = [../home]; }
}; ];
} }
]; )
};
})
devices) devices)

View File

@@ -191,9 +191,9 @@
layout = "us"; layout = "us";
variant = ""; variant = "";
}; };
displayManager.gdm.enable = true;
desktopManager.gnome.enable = true;
}; };
displayManager.gdm.enable = true;
desktopManager.gnome.enable = true;
pipewire = { pipewire = {
enable = true; enable = true;
alsa.enable = true; alsa.enable = true;

45
rpi/default.nix Normal file
View File

@@ -0,0 +1,45 @@
{
nixpkgs,
devices,
inputs,
overlays,
home-manager,
nur,
nixos-rpi,
...
}: (builtins.mapAttrs (
name: device:
nixpkgs.lib.nixosSystem {
system = device.system;
specialArgs = {
inherit device;
stablePkgs = inputs.nixpkgs-stable.legacyPackages.${device.system};
};
modules = [
nur.modules.nixos.default
inputs.sops-nix.nixosModules.sops
inputs.disko.nixosModules.disko
{nixpkgs.overlays = overlays;}
./${device.name}/configuration.nix
home-manager.nixosModules.home-manager
inputs.lanzaboote.nixosModules.lanzaboote
inputs.musnix.nixosModules.musnix
inputs.arion.nixosModules.arion
{
nixpkgs.config.allowUnfree = true;
home-manager = {
backupFileExtension = "bak";
useGlobalPkgs = true;
useUserPackages = true;
extraSpecialArgs = {
inherit inputs;
inherit device;
stablePkgs = inputs.nixpkgs-stable.legacyPackages.${device.system};
};
users.${device.user}.imports = [../home];
};
}
];
}
)
devices)