Skip to content

Commit

Permalink
Support both 17.09- and 18.03+ wrt system.nixos.version/release.
Browse files Browse the repository at this point in the history
  • Loading branch information
rbvermaa committed Feb 26, 2018
1 parent 60dcbd4 commit a48471b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion nix/ec2.nix
Expand Up @@ -150,7 +150,7 @@ let
then "/dev/" + builtins.substring 12 100 dev
else dev;

nixosVersion = builtins.substring 0 5 config.system.nixosVersion;
nixosVersion = builtins.substring 0 5 (config.system.nixos.version or config.system.nixosVersion);

amis = import <nixpkgs/nixos/modules/virtualisation/ec2-amis.nix>;

Expand Down
2 changes: 1 addition & 1 deletion nix/eval-machine-info.nix
Expand Up @@ -303,7 +303,7 @@ rec {
machines =
flip mapAttrs nodes (n: v': let v = scrubOptionValue v'; in
{ inherit (v.config.deployment) targetEnv targetPort targetHost encryptedLinksTo storeKeysOnMachine alwaysActivate owners keys hasFastConnection;
nixosRelease = v.config.system.nixosRelease or (removeSuffix v.config.system.nixosVersionSuffix v.config.system.nixosVersion);
nixosRelease = v.config.system.nixos.release or v.config.system.nixosRelease or (removeSuffix v.config.system.nixosVersionSuffix v.config.system.nixosVersion);
azure = optionalAttrs (v.config.deployment.targetEnv == "azure") v.config.deployment.azure;
ec2 = optionalAttrs (v.config.deployment.targetEnv == "ec2") v.config.deployment.ec2;
digitalOcean = optionalAttrs (v.config.deployment.targetEnv == "digitalOcean") v.config.deployment.digitalOcean;
Expand Down
14 changes: 10 additions & 4 deletions nixops/deployment.py
Expand Up @@ -498,15 +498,21 @@ def do_machine(m):
})

# Set system.stateVersion if the Nixpkgs version supports it.
if nixops.util.parse_nixos_version(defn.config["nixosRelease"]) >= ["15", "09"]:
nixos_version = nixops.util.parse_nixos_version(defn.config["nixosRelease"])
if nixos_version >= ["15", "09"]:
attrs_list.append({
('system', 'stateVersion'): Call(RawValue("lib.mkDefault"), m.state_version or defn.config["nixosRelease"])
})

if self.nixos_version_suffix:
attrs_list.append({
('system', 'nixosVersionSuffix'): self.nixos_version_suffix
})
if nixos_version >= [ "18", "03" ]:
attrs_list.append({
('system', 'nixos', 'versionSuffix'): self.nixos_version_suffix
})
else:
attrs_list.append({
('system', 'nixosVersionSuffix'): self.nixos_version_suffix
})

for m in active_machines.itervalues():
do_machine(m)
Expand Down

0 comments on commit a48471b

Please sign in to comment.