mirror of
https://github.com/LnL7/nix-darwin.git
synced 2024-12-14 11:57:34 +00:00
Pass system to darwinSystem rather than eval-config.
This allows us to specify what kind of darwinSystem we want to build, rather than determining it at evaluation time.
This commit is contained in:
parent
007d700e64
commit
9f7e95887f
5 changed files with 17 additions and 7 deletions
|
@ -79,6 +79,7 @@ A minimal example of using an existing configuration.nix:
|
||||||
|
|
||||||
outputs = { self, darwin, nixpkgs }: {
|
outputs = { self, darwin, nixpkgs }: {
|
||||||
darwinConfigurations."Johns-MacBook" = darwin.lib.darwinSystem {
|
darwinConfigurations."Johns-MacBook" = darwin.lib.darwinSystem {
|
||||||
|
system = "x86_64-darwin";
|
||||||
modules = [ ./configuration.nix ];
|
modules = [ ./configuration.nix ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -90,6 +91,7 @@ accessible as an argument, similar to pkgs and lib inside the configuration.
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
darwin.lib.darwinSystem {
|
darwin.lib.darwinSystem {
|
||||||
|
system = "x86_64-darwin";
|
||||||
modules = [ ... ];
|
modules = [ ... ];
|
||||||
inputs = { inherit darwin dotfiles nixpkgs; };
|
inputs = { inherit darwin dotfiles nixpkgs; };
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,10 @@
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
evalConfig = import ./eval-config.nix { inherit lib system; };
|
evalConfig = import ./eval-config.nix { inherit lib; };
|
||||||
|
|
||||||
eval = evalConfig {
|
eval = evalConfig {
|
||||||
|
inherit system;
|
||||||
modules = [ configuration ];
|
modules = [ configuration ];
|
||||||
inputs = { inherit nixpkgs; };
|
inputs = { inherit nixpkgs; };
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
{ lib, system ? builtins.currentSystem or "x86_64-darwin" }:
|
{ lib }:
|
||||||
|
|
||||||
{ modules
|
{ system ? builtins.currentSystem or "x86_64-darwin"
|
||||||
|
, modules
|
||||||
, inputs
|
, inputs
|
||||||
, baseModules ? import ./modules/module-list.nix
|
, baseModules ? import ./modules/module-list.nix
|
||||||
, specialArgs ? {}
|
, specialArgs ? { }
|
||||||
}@args:
|
}@args:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
@ -18,11 +19,14 @@ let
|
||||||
_file = ./eval-config.nix;
|
_file = ./eval-config.nix;
|
||||||
config = {
|
config = {
|
||||||
_module.args.pkgs = import inputs.nixpkgs config.nixpkgs;
|
_module.args.pkgs = import inputs.nixpkgs config.nixpkgs;
|
||||||
nixpkgs.system = system;
|
|
||||||
|
# This permits the configuration to override the passed-in
|
||||||
|
# system.
|
||||||
|
nixpkgs.system = lib.mkDefault system;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
eval = lib.evalModules (builtins.removeAttrs args ["inputs"] // {
|
eval = lib.evalModules (builtins.removeAttrs args [ "inputs" "system" ] // {
|
||||||
modules = modules ++ [ inputsModule pkgsModule ] ++ baseModules;
|
modules = modules ++ [ inputsModule pkgsModule ] ++ baseModules;
|
||||||
args = { inherit baseModules modules; };
|
args = { inherit baseModules modules; };
|
||||||
specialArgs = { modulesPath = builtins.toString ./modules; } // specialArgs;
|
specialArgs = { modulesPath = builtins.toString ./modules; } // specialArgs;
|
||||||
|
|
|
@ -7,7 +7,8 @@
|
||||||
# TODO handle multiple architectures.
|
# TODO handle multiple architectures.
|
||||||
evalConfig = import ./eval-config.nix { inherit (nixpkgs) lib; };
|
evalConfig = import ./eval-config.nix { inherit (nixpkgs) lib; };
|
||||||
|
|
||||||
darwinSystem = { modules, inputs ? {}, ... }@args: self.lib.evalConfig (args // {
|
darwinSystem = { modules, system, inputs ? { }, ... }@args: self.lib.evalConfig (args // {
|
||||||
|
inherit system;
|
||||||
inputs = { inherit nixpkgs; darwin = self; } // inputs;
|
inputs = { inherit nixpkgs; darwin = self; } // inputs;
|
||||||
modules = modules ++ [ self.darwinModules.flakeOverrides ];
|
modules = modules ++ [ self.darwinModules.flakeOverrides ];
|
||||||
});
|
});
|
||||||
|
@ -20,6 +21,7 @@
|
||||||
darwinModules.simple = ./modules/examples/simple.nix;
|
darwinModules.simple = ./modules/examples/simple.nix;
|
||||||
|
|
||||||
checks.x86_64-darwin.simple = (self.lib.darwinSystem {
|
checks.x86_64-darwin.simple = (self.lib.darwinSystem {
|
||||||
|
system = "x86_64-darwin";
|
||||||
modules = [ self.darwinModules.simple ];
|
modules = [ self.darwinModules.simple ];
|
||||||
}).system;
|
}).system;
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
# $ darwin-rebuild build --flake ./modules/examples#darwinConfigurations.simple.system \
|
# $ darwin-rebuild build --flake ./modules/examples#darwinConfigurations.simple.system \
|
||||||
# --override-input darwin .
|
# --override-input darwin .
|
||||||
darwinConfigurations."simple" = darwin.lib.darwinSystem {
|
darwinConfigurations."simple" = darwin.lib.darwinSystem {
|
||||||
|
system = "x86_64-darwin";
|
||||||
modules = [ configuration darwin.darwinModules.simple ];
|
modules = [ configuration darwin.darwinModules.simple ];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue