Something went wrong. Try again.
A Nordic stronghold for declarative computing.
flakes nix nixos nix-darwin
Something went wrong. Try again.
Nix
at old-config
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798{ inputs, lib, config, ... }:let mkNixos = { hostname, system, modules, stateVersion }: inputs.nixpkgs.lib.nixosSystem { inherit system; modules = modules ++ [ inputs.self.nixosModules.unfree-packages inputs.self.nixosModules.garbageCollector ({ ... }: { networking.hostName = hostname; nix.settings.experimental-features = [ "nix-command" "flakes" ];
# This value determines the NixOS release from which the default # settings for stateful data, like file locations and database versions # on your system were taken. It‘s perfectly fine and recommended to leave # this value at the release version of the first install of this system. # Before changing this value read the documentation for this option # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). system.stateVersion = stateVersion; # Did you read the comment? })]; specialArgs = { inherit inputs; }; };
mkDarwin = { hostname, system, modules, stateVersion }: inputs.darwin.lib.darwinSystem { inherit system; inputs = { nixpkgs = inputs.nixpkgs-darwin; }; modules = [ inputs.self.darwinModules.unfree-packages inputs.self.darwinModules.garbageCollector ({ ... }: { nix.enable = true; networking.hostName = hostname; networking.computerName = hostname; nix.settings.experimental-features = [ "nix-command" "flakes" ];
# Used for backwards compatibility, please read the changelog before changing. # $ darwin-rebuild changelog system.stateVersion = stateVersion; })] ++ modules; specialArgs = { inherit inputs; }; };
isDarwin = system: let parsed = lib.systems.elaborate { system = system; }; in parsed.isDarwin;in{ options.hosts = lib.mkOption { type = lib.types.attrsOf (lib.types.submodule ({ name, ... }: { options = { hostname = lib.mkOption { type = lib.types.str; default = name; description = "Hostname for this system"; };
system = lib.mkOption { type = lib.types.str; default = "x86_64-linux"; description = "System architecture"; };
modules = lib.mkOption { type = lib.types.listOf lib.types.unspecified; default = []; description = "List of modules to include"; };
stateVersion = lib.mkOption { type = lib.types.oneOf [ lib.types.str lib.types.int ]; default = "24.05"; description = "State version for the system"; }; }; })); default = {}; description = "Host definitions"; };
# NixOS configurations config.flake.nixosConfigurations = lib.mapAttrs (name: cfg: mkNixos { inherit (cfg) hostname system modules stateVersion; }) (lib.filterAttrs (name: cfg: !isDarwin cfg.system) config.hosts);
# Darwin configurations config.flake.darwinConfigurations = lib.mapAttrs (name: cfg: mkDarwin { inherit (cfg) hostname system modules stateVersion; }) (lib.filterAttrs (name: cfg: isDarwin cfg.system) config.hosts);}