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

120
flake.lock generated
View File

@@ -207,6 +207,22 @@
"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": {
"inputs": {
"flake-parts": "flake-parts_3",
@@ -1833,6 +1849,53 @@
"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": {
"locked": {
"lastModified": 1706487304,
@@ -1945,6 +2008,22 @@
}
},
"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": {
"lastModified": 1749794982,
"narHash": "sha256-Kh9K4taXbVuaLC0IL+9HcfvxsSUx8dPB5s5weJcc9pc=",
@@ -1960,22 +2039,6 @@
"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": {
"locked": {
"lastModified": 1644486793,
@@ -1993,6 +2056,22 @@
}
},
"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": {
"lastModified": 1749794982,
"narHash": "sha256-Kh9K4taXbVuaLC0IL+9HcfvxsSUx8dPB5s5weJcc9pc=",
@@ -2060,7 +2139,7 @@
"inputs": {
"flake-compat": "flake-compat_7",
"flake-utils": "flake-utils_10",
"nixpkgs": "nixpkgs_6"
"nixpkgs": "nixpkgs_7"
},
"locked": {
"lastModified": 1672582520,
@@ -2081,7 +2160,7 @@
"inputs": {
"flake-compat": "flake-compat_8",
"flake-utils": "flake-utils_11",
"nixpkgs": "nixpkgs_7"
"nixpkgs": "nixpkgs_8"
},
"locked": {
"lastModified": 1713028366,
@@ -2100,7 +2179,7 @@
"nur": {
"inputs": {
"flake-parts": "flake-parts_6",
"nixpkgs": "nixpkgs_8",
"nixpkgs": "nixpkgs_9",
"treefmt-nix": "treefmt-nix"
},
"locked": {
@@ -2284,7 +2363,8 @@
"neogit": "neogit",
"nix-darwin": "nix-darwin",
"nix-index-database": "nix-index-database",
"nixpkgs": "nixpkgs_5",
"nixos-rpi": "nixos-rpi",
"nixpkgs": "nixpkgs_6",
"nixpkgs-master": "nixpkgs-master",
"nixpkgs-stable": "nixpkgs-stable",
"nixvim": "nixvim",

View File

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

View File

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

View File

@@ -6,41 +6,40 @@
home-manager,
nur,
...
}:
builtins.listToAttrs (builtins.map (device: {
name = device.name;
value = nixpkgs.lib.nixosSystem {
system = device.system;
specialArgs = {
inherit device;
stablePkgs = inputs.nixpkgs-stable.legacyPackages.${device.system};
lanzaboote = inputs.lanzaboote;
};
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};
}: (builtins.mapAttrs (
name: device:
nixpkgs.lib.nixosSystem {
system = device.system;
specialArgs = {
inherit device;
stablePkgs = inputs.nixpkgs-stable.legacyPackages.${device.system};
lanzaboote = inputs.lanzaboote;
};
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];
};
users.${device.user}.imports = [../home];
};
}
];
};
})
}
];
}
)
devices)

View File

@@ -191,9 +191,9 @@
layout = "us";
variant = "";
};
displayManager.gdm.enable = true;
desktopManager.gnome.enable = true;
};
displayManager.gdm.enable = true;
desktopManager.gnome.enable = true;
pipewire = {
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)