Deployment and lifecycle management for Nix
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

agent: clean up seed handling

+26 -22
+26 -22
apps/sower_agent/lib/sower_agent/seed.ex
··· 4 4 require Logger 5 5 6 6 def activate(%Seed{seed_type: "home-manager"} = seed) do 7 - if Application.get_env(:sower_agent, :enable_activation, false) do 7 + if Application.get_env(:sower_agent, :enable_activation, true) do 8 8 case System.cmd("#{seed.artifact}/activate", [], 9 9 into: [], 10 10 lines: 1024, ··· 24 24 end 25 25 26 26 def activate(%Seed{seed_type: "nixos"} = seed) do 27 - {_, 0} = 28 - maybe_sudo_cmd( 29 - "nix-env", 30 - [ 31 - "--set", 32 - "--profile", 33 - Nix.NixOS.profile_path(), 34 - seed.artifact 35 - ] 36 - ) 27 + if Application.get_env(:sower_agent, :enable_activation, true) do 28 + {_, 0} = 29 + maybe_sudo_cmd( 30 + "nix-env", 31 + [ 32 + "--set", 33 + "--profile", 34 + Nix.NixOS.profile_path(), 35 + seed.artifact 36 + ] 37 + ) 37 38 38 - case maybe_sudo_cmd("#{seed.artifact}/bin/switch-to-configuration", ["switch"], 39 - into: [], 40 - lines: 1024, 41 - stderr_to_stdout: true 42 - ) do 43 - {output, 0} -> 44 - Logger.debug(output: output) 45 - {:ok, output} 39 + case maybe_sudo_cmd("#{seed.artifact}/bin/switch-to-configuration", ["switch"], 40 + into: [], 41 + lines: 1024, 42 + stderr_to_stdout: true 43 + ) do 44 + {output, 0} -> 45 + Logger.debug(output: output) 46 + {:ok, output} 46 47 47 - {output, code} -> 48 - Logger.error(msg: "Failed to activate", output: output, return_code: code) 49 - {:error, code} 48 + {output, code} -> 49 + Logger.error(msg: "Failed to activate", output: output, return_code: code) 50 + {:error, code} 51 + end 52 + else 53 + {:ok, ["noop"]} 50 54 end 51 55 end 52 56