From edaed825650eea32878441d3b8c7eb40e8877882 Mon Sep 17 00:00:00 2001 From: notgne2 Date: Mon, 28 Sep 2020 16:17:31 -0700 Subject: Add examples --- examples/system/hello.nix | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 examples/system/hello.nix (limited to 'examples/system/hello.nix') 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 +'' -- cgit v1.2.3 From 8d21dd335e5259dadf832a5d1a7c72b9dd1f4400 Mon Sep 17 00:00:00 2001 From: notgne2 Date: Tue, 29 Sep 2020 15:10:06 -0700 Subject: Add license information, reformat Nix files, clean up --- examples/system/hello.nix | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'examples/system/hello.nix') diff --git a/examples/system/hello.nix b/examples/system/hello.nix index 8c207f1..df57308 100644 --- a/examples/system/hello.nix +++ b/examples/system/hello.nix @@ -1,3 +1,7 @@ +# SPDX-FileCopyrightText: 2020 Serokell +# +# SPDX-License-Identifier: MPL-2.0 + nixpkgs: let pkgs = nixpkgs.legacyPackages.x86_64-linux; @@ -14,11 +18,10 @@ let text = mkService "hello" { unitConfig.WantedBy = [ "multi-user.target" ]; path = [ pkgs.hello ]; - script = "hello -g lel; touch $HOME/oof"; + script = "hello"; }; }; -in -pkgs.writeShellScriptBin "activate" '' +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 -- cgit v1.2.3