Skip to content

Commit

Permalink
Revert "network: Add nixpkgs attribute for passing custom nixpkgs"
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamc committed Jul 24, 2020
1 parent 0330ead commit c082c5b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
16 changes: 3 additions & 13 deletions nix/eval-machine-info.nix
Expand Up @@ -41,24 +41,20 @@ let
if network ? nixpkgs
then (builtins.head (network.nixpkgs)).lib.nixosSystem
else throw "NixOps network must have a 'nixpkgs' attribute"
else import (pkgs.path + "/nixos/lib/eval-config.nix");
else import <nixpkgs/nixos/lib/eval-config.nix>;

pkgs = if flakeUri != null
then
if network ? nixpkgs
then (builtins.head network.nixpkgs).legacyPackages.${system}
else throw "NixOps network must have a 'nixpkgs' attribute"
else (builtins.head (network.network)).nixpkgs or (import <nixpkgs> { inherit system; });
else import <nixpkgs> { inherit system; };

inherit (pkgs) lib;

# Expose path to imported nixpkgs (currently only used to find version suffix)
nixpkgs = builtins.unsafeDiscardStringContext pkgs.path;

in rec {

inherit networks network;
inherit nixpkgs;

importedPluginNixExprs = map
(expr: import expr)
Expand Down Expand Up @@ -86,7 +82,6 @@ in rec {
in
{ name = machineName;
value = evalConfig {
inherit pkgs;
modules =
modules ++
defaults ++
Expand Down Expand Up @@ -177,11 +172,7 @@ in rec {
pluginDeploymentConfigExporters
));

network =
builtins.removeAttrs
(lib.fold (as: bs: as // bs) {} (network'.network or []))
[ "nixpkgs" ] # Not serialisable
;
network = lib.fold (as: bs: as // bs) {} (network'.network or []);

resources =
let
Expand Down Expand Up @@ -254,5 +245,4 @@ in rec {
getNixOpsArgs = fs: lib.zipAttrs (lib.unique (lib.concatMap fileToArgs (getNixOpsExprs fs)));

nixopsArguments = getNixOpsArgs networkExprs;

}
8 changes: 5 additions & 3 deletions nixops/deployment.py
Expand Up @@ -791,9 +791,11 @@ def build_configs(
# Set the NixOS version suffix, if we're building from Git.
# That way ‘nixos-version’ will show something useful on the
# target machines.
#
# TODO: Implement flake compatible version
nixos_path = str(self.evaluate_config("nixpkgs"))
nixos_path = subprocess.check_output(
["nix-instantiate", "--find-file", "nixpkgs/nixos"]
+ self._nix_path_flags(),
text=True,
).rstrip()
get_version_script = nixos_path + "/modules/installer/tools/get-version-suffix"
if os.path.exists(nixos_path + "/.git") and os.path.exists(get_version_script):
self.nixos_version_suffix = subprocess.check_output(
Expand Down

0 comments on commit c082c5b

Please sign in to comment.