mirror of
https://github.com/willemml/dotfiles.nix.git
synced 2025-04-13 19:57:19 +00:00
fix nix_path for darwin-option
This commit is contained in:
parent
dfc17e0b17
commit
6a027c3971
3 changed files with 97 additions and 4 deletions
|
@ -32,7 +32,7 @@
|
|||
pkgs = throw "nixpkgs eval";
|
||||
};
|
||||
|
||||
home-manager-config = {
|
||||
user-config = {
|
||||
home-manager.useGlobalPkgs = true;
|
||||
home-manager.useUserPackages = true;
|
||||
home-manager.extraSpecialArgs = { inherit nurNoPkgs pkgs; inputs = { inherit (inputs); }; };
|
||||
|
@ -49,11 +49,12 @@
|
|||
{
|
||||
darwinConfigurations = {
|
||||
zeus = darwin.lib.darwinSystem {
|
||||
inherit system pkgs;
|
||||
inherit system pkgs inputs;
|
||||
modules = [
|
||||
./modules/nix.nix
|
||||
./system/darwin.nix
|
||||
home-manager.darwinModules.home-manager
|
||||
home-manager-config
|
||||
user-config
|
||||
];
|
||||
};
|
||||
};
|
||||
|
|
83
modules/nix.nix
Normal file
83
modules/nix.nix
Normal file
|
@ -0,0 +1,83 @@
|
|||
# https://github.com/LnL7/nix-darwin/issues/277#issuecomment-992866471
|
||||
|
||||
{ config, lib, pkgs, inputs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.nix;
|
||||
|
||||
nixRegistry = builtins.mapAttrs (name: value: { flake = value; }) inputs;
|
||||
etcNixInputs = pkgs.runCommandNoCC "etc-nix-inputs"
|
||||
{
|
||||
inputNames = builtins.attrNames inputs;
|
||||
inputPaths = builtins.map (x: x.outPath) (builtins.attrValues inputs);
|
||||
} ''
|
||||
mkdir -p $out
|
||||
inputNames=($inputNames)
|
||||
inputPaths=($inputPaths)
|
||||
for (( i=0; i<''${#inputNames[@]}; i++)); do
|
||||
source=''${inputPaths[$i]}
|
||||
name=''${inputNames[$i]}
|
||||
if [[ -f $source/default.nix ]]; then
|
||||
ln -s $source $out/$name
|
||||
fi
|
||||
done
|
||||
'';
|
||||
in
|
||||
|
||||
# Based on flake-utils-plus#nixosModules.autoGenFromInputs
|
||||
# https://github.com/gytis-ivaskevicius/flake-utils-plus/blob/master/lib/options.nix
|
||||
#
|
||||
# We're not using that directly because we don't need the rest of the flake, and to work around
|
||||
# https://github.com/gytis-ivaskevicius/flake-utils-plus/issues/105 and
|
||||
# https://github.com/gytis-ivaskevicius/flake-utils-plus/issues/107
|
||||
|
||||
{
|
||||
options = {
|
||||
nix.generateNixPathFromInputs = mkOption {
|
||||
type = types.bool;
|
||||
description = ''
|
||||
If set, NIX_PATH will be generated from available inputs.
|
||||
This requires `nix.linkInputs` to be enabled, and setting this will default
|
||||
`nix.linkInputs` to true.
|
||||
'';
|
||||
default = false;
|
||||
example = true;
|
||||
};
|
||||
nix.generateRegistryFromInputs = mkOption {
|
||||
type = types.bool;
|
||||
description = ''
|
||||
If set, the system Nix registry will be generated from available inputs.
|
||||
Otherwise, the registry will still include the `self` flake.
|
||||
'';
|
||||
default = false;
|
||||
example = true;
|
||||
};
|
||||
nix.linkInputs = mkOption {
|
||||
type = types.bool;
|
||||
description = "If set, inputs will be symlinked into /etc/nix/inputs.";
|
||||
example = true;
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
assertions = [{
|
||||
assertion = cfg.generateNixPathFromInputs -> cfg.linkInputs;
|
||||
message = "nix.generateNixPathFromInputs requires nix.linkInputs";
|
||||
}];
|
||||
|
||||
nix.linkInputs = mkDefault cfg.generateNixPathFromInputs;
|
||||
|
||||
nix.registry =
|
||||
if cfg.generateRegistryFromInputs
|
||||
then nixRegistry
|
||||
else { self.flake = inputs.self; };
|
||||
|
||||
environment.etc."nix/inputs" = mkIf cfg.linkInputs {
|
||||
source = etcNixInputs;
|
||||
};
|
||||
|
||||
nix.nixPath = mkIf cfg.generateNixPathFromInputs [ "/etc/nix/inputs" ];
|
||||
};
|
||||
}
|
|
@ -3,7 +3,16 @@
|
|||
{
|
||||
environment.systemPackages = with pkgs; [ ];
|
||||
|
||||
nix.package = pkgs.nix;
|
||||
nix = {
|
||||
extraOptions = ''
|
||||
experimental-features = nix-command flakes
|
||||
extra-trusted-users = willem
|
||||
'';
|
||||
generateRegistryFromInputs = true;
|
||||
generateNixPathFromInputs = true;
|
||||
linkInputs = true;
|
||||
package = pkgs.nix;
|
||||
};
|
||||
|
||||
programs.bash.enable = true;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue