diff options
author | notgne2 | 2020-09-28 16:17:31 -0700 |
---|---|---|
committer | notgne2 | 2020-09-28 16:17:31 -0700 |
commit | edaed825650eea32878441d3b8c7eb40e8877882 (patch) | |
tree | ba0e313a5cd2711de11e9fe9d973073171519ee5 /examples/system/hello.nix | |
parent | 239d0f8999b47e9e76589ee1fa2d9f3459c47335 (diff) |
Add examples
Diffstat (limited to '')
-rw-r--r-- | examples/system/hello.nix | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/examples/system/hello.nix b/examples/system/hello.nix new file mode 100644 index 0000000..8c207f1 --- /dev/null +++ b/examples/system/hello.nix @@ -0,0 +1,27 @@ +nixpkgs: +let + pkgs = nixpkgs.legacyPackages.x86_64-linux; + generateSystemd = type: name: config: + (nixpkgs.lib.nixosSystem { + modules = [{ systemd."${type}s".${name} = config; }]; + system = "x86_64-linux"; + }).config.systemd.units."${name}.${type}".text; + + mkService = generateSystemd "service"; + + service = pkgs.writeTextFile { + name = "hello.service"; + text = mkService "hello" { + unitConfig.WantedBy = [ "multi-user.target" ]; + path = [ pkgs.hello ]; + script = "hello -g lel; touch $HOME/oof"; + }; + }; +in +pkgs.writeShellScriptBin "activate" '' + mkdir -p $HOME/.config/systemd/user + rm $HOME/.config/systemd/user/hello.service + ln -s ${service} $HOME/.config/systemd/user/hello.service + systemctl --user daemon-reload + systemctl --user restart hello +'' |