infra/nix/default.nix
Stefan Junker 522d7279bd nix: set NIX_PATH per device versions at buildtime
Previously all devices would have NIX_PATH set on the common verion file
defindd in *nix/variables/versions.nix*. Now NIX_PATH is populated with
the versions of the respective device.
2020-10-16 22:31:01 +02:00

34 lines
1.2 KiB
Nix

{ versionsPath }:
let
channelVersions = (import versionsPath);
mkChannelSource = channel:
let
channelVersion = builtins.getAttr channel channelVersions;
in builtins.fetchGit {
# Descriptive name to make the store path easier to identify
name = "nixpkgs-channels-${channel}";
url = if builtins.hasAttr "url" channelVersion
then channelVersion."url"
else "https://github.com/NixOS/nixpkgs-channels/"
;
ref = (builtins.getAttr channel channelVersions)."ref";
rev = (builtins.getAttr channel channelVersions)."rev";
};
nixPath = builtins.foldl' (sum: elem: sum +":" + builtins.concatStringsSep "=" elem) "" [
[ "nixpkgs" (mkChannelSource "channelsNixosStable") ]
[ "nixos" (mkChannelSource "channelsNixosStable" + "/nixos") ]
[ "channels-nixos-stable" (mkChannelSource "channelsNixosStable") ]
[ "channels-nixos-unstable" (mkChannelSource "channelsNixosUnstable") ]
[ "nixpkgs-master" (mkChannelSource "nixpkgsMaster") ]
[ "home-manager-module" (mkChannelSource "homeManagerModule") ]
];
pkgs = import (mkChannelSource "channelsNixosStable") {};
in
{
inherit nixPath;
channelSources = pkgs.writeText "channels.rc" ''
export NIX_PATH=${nixPath}
'';
}