Simplify flake with variables

This commit is contained in:
Jimbo 2024-10-12 21:14:55 -04:00
parent c380052b0c
commit c3193845a4

112
flake.nix
View file

@ -2,7 +2,6 @@
description = "Jimbo's systems as a flake"; description = "Jimbo's systems as a flake";
inputs = { inputs = {
# Nixpkgs
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05"; nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable"; nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
nur.url = "github:nix-community/NUR"; nur.url = "github:nix-community/NUR";
@ -37,15 +36,16 @@
... ...
} @inputs: let } @inputs: let
inherit (self) outputs; inherit (self) outputs;
forAllSystems = nixpkgs.lib.genAttrs [ mkNixos = modules: nixpkgs.lib.nixosSystem {
"aarch64-linux" inherit modules;
"x86_64-linux" specialArgs = { inherit inputs outputs; };
]; };
in rec {
# Your custom packages
# Accessible through 'nix build', 'nix shell', etc
packages = forAllSystems (system: import ./extras/pkgs nixpkgs.legacyPackages.${system});
mkHome = modules: pkgs: home-manager.lib.homeManagerConfiguration {
inherit modules pkgs;
extraSpecialArgs = { inherit inputs outputs; };
};
in rec {
# Your custom packages and modifications, exported as overlays # Your custom packages and modifications, exported as overlays
overlays = import ./extras/overlays.nix { inherit inputs; }; overlays = import ./extras/overlays.nix { inherit inputs; };
@ -59,76 +59,40 @@
# NixOS config entrypoint, use 'nixos-rebuild --flake .#your-hostname' # NixOS config entrypoint, use 'nixos-rebuild --flake .#your-hostname'
nixosConfigurations = { nixosConfigurations = {
JimDesktop = nixpkgs.lib.nixosSystem { JimDesktop = mkNixos [
specialArgs = {inherit inputs outputs;}; ./system/hosts/JimDesktop/configuration.nix
modules = [ lanzaboote.nixosModules.lanzaboote
./system/hosts/JimDesktop/configuration.nix ];
lanzaboote.nixosModules.lanzaboote JimServer = mkNixos [
]; ./system/hosts/JimServer/configuration.nix
}; mailserver.nixosModule
JimServer = nixpkgs.lib.nixosSystem { ];
specialArgs = {inherit inputs outputs;}; JimPine = mkNixos [
modules = [ ./system/hosts/JimPine/configuration.nix
./system/hosts/JimServer/configuration.nix hardware.nixosModules.pine64-pinebook-pro
mailserver.nixosModule ];
];
};
JimPine = nixpkgs.lib.nixosSystem {
specialArgs = {inherit inputs outputs;};
modules = [
./system/hosts/JimPine/configuration.nix
hardware.nixosModules.pine64-pinebook-pro
];
};
JimLenovo = nixpkgs.lib.nixosSystem {
specialArgs = {inherit inputs outputs;};
modules = [
./system/hosts/JimLenovo/configuration.nix
];
};
}; };
# Home-manager configuration, use 'home-manager --flake .#your-username@your-hostname' # Home-manager configuration, use 'home-manager --flake .#your-username@your-hostname'
homeConfigurations = { homeConfigurations = {
"jimbo@JimDesktop" = home-manager.lib.homeManagerConfiguration { "jimbo@JimDesktop" = mkHome [
pkgs = nixpkgs.legacyPackages.x86_64-linux; ./home/hosts/JimDesktop/home.nix
extraSpecialArgs = {inherit inputs outputs;}; nur.nixosModules.nur
modules = [ ] nixpkgs.legacyPackages."x86_64-linux";
./home/hosts/JimDesktop/home.nix
nur.nixosModules.nur "jimbo@JimServer" = mkHome [
]; ./home/hosts/JimServer/home.nix
}; ] nixpkgs.legacyPackages.x86_64-linux;
"jimbo@JimServer" = home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages.x86_64-linux; "jimbo@JimPine" = mkHome [
extraSpecialArgs = {inherit inputs outputs;}; ./home/hosts/JimPine/home.nix
modules = [ nur.nixosModules.nur
./home/hosts/JimServer/home.nix ] nixpkgs.legacyPackages.aarch64-linux;
];
};
"jimbo@JimPine" = home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages.aarch64-linux;
extraSpecialArgs = {inherit inputs outputs;};
modules = [
./home/hosts/JimPine/home.nix
nur.nixosModules.nur
];
};
"jimbo@JimLenovo" = home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages.x86_64-linux;
extraSpecialArgs = {inherit inputs outputs;};
modules = [
./home/hosts/JimLenovo/home.nix
nur.nixosModules.nur
];
};
# Derivation for ssh envrionments on other people's servers # Derivation for ssh envrionments on other people's servers
"jimbo@JimTerminal" = home-manager.lib.homeManagerConfiguration { "jimbo@JimTerminal" = mkHome [
pkgs = nixpkgs.legacyPackages.x86_64-linux; ./home/hosts/JimTerminal/home.nix
extraSpecialArgs = {inherit inputs outputs;}; ] nixpkgs.legacyPackages.x86_64-linux;
modules = [
./home/hosts/JimTerminal/home.nix
];
};
}; };
}; };
} }