diff options
Diffstat (limited to '_pastebins')
-rw-r--r-- | _pastebins/gnu-guix-systemd-daemon-for-nixos.md | 24 | ||||
-rw-r--r-- | _pastebins/guix-builder-user-creation-commands.md | 17 | ||||
-rw-r--r-- | _pastebins/guix-users-in-nixos-system-configuration.md | 44 | ||||
-rw-r--r-- | _pastebins/nix-pinning.md | 29 | ||||
-rw-r--r-- | _pastebins/nix-string-padding.md | 10 | ||||
-rw-r--r-- | _pastebins/rpn-macro-setup.md | 27 |
6 files changed, 151 insertions, 0 deletions
diff --git a/_pastebins/gnu-guix-systemd-daemon-for-nixos.md b/_pastebins/gnu-guix-systemd-daemon-for-nixos.md new file mode 100644 index 0000000..0580993 --- /dev/null +++ b/_pastebins/gnu-guix-systemd-daemon-for-nixos.md @@ -0,0 +1,24 @@ +--- +title: GNU Guix systemd daemon for NixOS +date: 2018-07-13 +layout: pastebin +lang: en +--- + +```nix + # Derived from Guix guix-daemon.service.in + # https://git.savannah.gnu.org/cgit/guix.git/tree/etc/guix-daemon.service.in?id=00c86a888488b16ce30634d3a3a9d871ed6734a2 + systemd.services.guix-daemon = { + enable = true; + description = "Build daemon for GNU Guix"; + serviceConfig = { + ExecStart = "/var/guix/profiles/per-user/root/guix-profile/bin/guix-daemon --build-users-group=guixbuild"; + Environment="GUIX_LOCPATH=/root/.guix-profile/lib/locale"; + RemainAfterExit="yes"; + StandardOutput="syslog"; + StandardError="syslog"; + TaskMax= 8192; + }; + wantedBy = [ "multi-user.target" ]; + }; +``` diff --git a/_pastebins/guix-builder-user-creation-commands.md b/_pastebins/guix-builder-user-creation-commands.md new file mode 100644 index 0000000..356fe4b --- /dev/null +++ b/_pastebins/guix-builder-user-creation-commands.md @@ -0,0 +1,17 @@ +--- +title: Guix builder user creation commands +date: 2018-07-13 +layout: pastebin +lang: en +--- + +```shell +groupadd --system guixbuild +for i in `seq -w 1 10`; +do + useradd -g guixbuild -G guixbuild \ + -d /var/empty -s `which nologin` \ + -c "Guix build user $i" --system \ + guixbuilder$i; +done +``` diff --git a/_pastebins/guix-users-in-nixos-system-configuration.md b/_pastebins/guix-users-in-nixos-system-configuration.md new file mode 100644 index 0000000..f7c8440 --- /dev/null +++ b/_pastebins/guix-users-in-nixos-system-configuration.md @@ -0,0 +1,44 @@ +--- +title: Guix users in NixOS system configuration +date: 2018-07-13 +layout: pastebin +lang: en +--- + +```nix + users = { + mutableUsers = false; + + extraUsers = + let + andrehUser = { + andreh = { + # my custom user config + }; + }; + # From the Guix manual: + # https://www.gnu.org/software/guix/manual/en/html_node/Build-Environment-Setup.html#Build-Environment-Setup + buildUser = (i: + { + "guixbuilder${i}" = { # guixbuilder$i + group = "guixbuild"; # -g guixbuild + extraGroups = ["guixbuild"]; # -G guixbuild + home = "/var/empty"; # -d /var/empty + shell = pkgs.nologin; # -s `which nologin` + description = "Guix build user ${i}"; # -c "Guix buid user $i" + isSystemUser = true; # --system + }; + } + ); + in + # merge all users + pkgs.lib.fold (str: acc: acc // buildUser str) + andrehUser + # for i in `seq -w 1 10` + (map (pkgs.lib.fixedWidthNumber 2) (builtins.genList (n: n+1) 10)); + + extraGroups.guixbuild = { + name = "guixbuild"; + }; + }; +``` diff --git a/_pastebins/nix-pinning.md b/_pastebins/nix-pinning.md new file mode 100644 index 0000000..4239511 --- /dev/null +++ b/_pastebins/nix-pinning.md @@ -0,0 +1,29 @@ +--- +title: Nix pinning +date: 2018-07-11 +layout: pastebin +lang: en +--- + +```nix +let + # Pin the nixpkgs version + stdenv = pkgs.stdenv; + pkgsOriginal = import <nixpkgs> {}; + pkgsSrc = pkgsOriginal.fetchzip { + url = "https://github.com/NixOS/nixpkgs/archive/18.03.zip"; + sha256 = "0hk4y2vkgm1qadpsm4b0q1vxq889jhxzjx3ragybrlwwg54mzp4f"; + }; + + pkgs = import (pkgsSrc) {}; + + buildNodeJS = pkgs.callPackage <nixpkgs/pkgs/development/web/nodejs/nodejs.nix> {}; + +in rec { + nodeFromNVMRC = buildNodeJS { + version = "8.7.0"; + sha256 = "16mml3cwjnq7yf9yd67d2dybav3nvbnk89fkixs1wz7fd26d05ss"; + patches = []; + }; +} +``` diff --git a/_pastebins/nix-string-padding.md b/_pastebins/nix-string-padding.md new file mode 100644 index 0000000..8de9048 --- /dev/null +++ b/_pastebins/nix-string-padding.md @@ -0,0 +1,10 @@ +--- +title: Nix string padding +date: 2018-07-13 +layout: pastebin +lang: en +--- + +```nix +padString = (n: if n < 10 then "0" + toString n else toString n) +``` diff --git a/_pastebins/rpn-macro-setup.md b/_pastebins/rpn-macro-setup.md new file mode 100644 index 0000000..5ebe3ab --- /dev/null +++ b/_pastebins/rpn-macro-setup.md @@ -0,0 +1,27 @@ +--- +title: RPN macro setup +date: 2016-04-05 +layout: pastebin +lang: en +--- + +```lisp +(defmacro rpn (body) + (rpn-expander body)) + +(defun rpn-expander (body) + (mapcar (lambda (x) + (if (listp x) + (rpn-expander x) + x)) + (reverse body))) + +(rpn ((2 1 +) 2 *)) +; => 6 + +#| +Just a quick stub. + +One could easily improve #'RPN-EXPANDER in order to better suit one's needs. +|# +``` |