From 960e4410f76801356ebd42801c914b2910a302a7 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Mon, 18 Nov 2024 08:21:58 -0300 Subject: v0 migration to mkwb --- src/content/pastebins/2018/07/11/nix-pinning.adoc | 38 ++++++++++ .../pastebins/2018/07/13/guix-nixos-systemd.adoc | 33 +++++++++ .../pastebins/2018/07/13/guixbuilder-nixos.adoc | 53 +++++++++++++ src/content/pastebins/2018/07/13/guixbuilder.adoc | 26 +++++++ src/content/pastebins/2018/07/13/nix-strpad.adoc | 19 +++++ src/content/pastebins/2018/07/25/nix-exps.adoc | 58 +++++++++++++++ src/content/pastebins/2018/07/25/nix-showdrv.adoc | 86 ++++++++++++++++++++++ 7 files changed, 313 insertions(+) create mode 100644 src/content/pastebins/2018/07/11/nix-pinning.adoc create mode 100644 src/content/pastebins/2018/07/13/guix-nixos-systemd.adoc create mode 100644 src/content/pastebins/2018/07/13/guixbuilder-nixos.adoc create mode 100644 src/content/pastebins/2018/07/13/guixbuilder.adoc create mode 100644 src/content/pastebins/2018/07/13/nix-strpad.adoc create mode 100644 src/content/pastebins/2018/07/25/nix-exps.adoc create mode 100644 src/content/pastebins/2018/07/25/nix-showdrv.adoc (limited to 'src/content/pastebins/2018') diff --git a/src/content/pastebins/2018/07/11/nix-pinning.adoc b/src/content/pastebins/2018/07/11/nix-pinning.adoc new file mode 100644 index 0000000..2d35e09 --- /dev/null +++ b/src/content/pastebins/2018/07/11/nix-pinning.adoc @@ -0,0 +1,38 @@ +--- + +title: Nix pinning + +date: 2018-07-11 + +layout: post + +lang: en + +eu_categories: nix + +ref: nix-pinning + +--- + +```nix +let + # Pin the nixpkgs version + stdenv = pkgs.stdenv; + pkgsOriginal = import {}; + pkgsSrc = pkgsOriginal.fetchzip { + url = "https://github.com/NixOS/nixpkgs/archive/18.03.zip"; + sha256 = "0hk4y2vkgm1qadpsm4b0q1vxq889jhxzjx3ragybrlwwg54mzp4f"; + }; + + pkgs = import (pkgsSrc) {}; + + buildNodeJS = pkgs.callPackage {}; + +in rec { + nodeFromNVMRC = buildNodeJS { + version = "8.7.0"; + sha256 = "16mml3cwjnq7yf9yd67d2dybav3nvbnk89fkixs1wz7fd26d05ss"; + patches = []; + }; +} +``` diff --git a/src/content/pastebins/2018/07/13/guix-nixos-systemd.adoc b/src/content/pastebins/2018/07/13/guix-nixos-systemd.adoc new file mode 100644 index 0000000..c2b8b62 --- /dev/null +++ b/src/content/pastebins/2018/07/13/guix-nixos-systemd.adoc @@ -0,0 +1,33 @@ +--- + +title: GNU Guix systemd daemon for NixOS + +date: 2018-07-13 + +layout: post + +lang: en + +eu_categories: nix,guix + +ref: gnu-guix-systemd-daemon-for-nixos + +--- + +```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/src/content/pastebins/2018/07/13/guixbuilder-nixos.adoc b/src/content/pastebins/2018/07/13/guixbuilder-nixos.adoc new file mode 100644 index 0000000..880d347 --- /dev/null +++ b/src/content/pastebins/2018/07/13/guixbuilder-nixos.adoc @@ -0,0 +1,53 @@ +--- + +title: Guix users in NixOS system configuration + +date: 2018-07-13 + +layout: post + +lang: en + +eu_categories: nix,guix + +ref: guix-users-in-nixos-system-configuration + +--- + +```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/src/content/pastebins/2018/07/13/guixbuilder.adoc b/src/content/pastebins/2018/07/13/guixbuilder.adoc new file mode 100644 index 0000000..82204a8 --- /dev/null +++ b/src/content/pastebins/2018/07/13/guixbuilder.adoc @@ -0,0 +1,26 @@ +--- + +title: Guix builder user creation commands + +date: 2018-07-13 + +layout: post + +lang: en + +eu_categories: guix + +ref: guix-builder-user-creation-commands + +--- + +```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/src/content/pastebins/2018/07/13/nix-strpad.adoc b/src/content/pastebins/2018/07/13/nix-strpad.adoc new file mode 100644 index 0000000..359bda5 --- /dev/null +++ b/src/content/pastebins/2018/07/13/nix-strpad.adoc @@ -0,0 +1,19 @@ +--- + +title: Nix string padding + +date: 2018-07-13 + +layout: post + +lang: en + +eu_categories: nix + +ref: nix-string-padding + +--- + +```nix +padString = (n: if n < 10 then "0" + toString n else toString n) +``` diff --git a/src/content/pastebins/2018/07/25/nix-exps.adoc b/src/content/pastebins/2018/07/25/nix-exps.adoc new file mode 100644 index 0000000..23d75b6 --- /dev/null +++ b/src/content/pastebins/2018/07/25/nix-exps.adoc @@ -0,0 +1,58 @@ +--- + +title: Nix exps + +date: 2018-07-25 + +layout: post + +lang: en + +eu_categories: nix + +ref: nix-exps + +--- + +```nix +let + pkgsOriginal = import {}; + pkgsSrc = pkgsOriginal.fetchzip { + url = "https://github.com/NixOS/nixpkgs/archive/18.03.zip"; + sha256 = "0hk4y2vkgm1qadpsm4b0q1vxq889jhxzjx3ragybrlwwg54mzp4f"; + }; + pkgs = import (pkgsSrc) {}; + stdenv = pkgs.stdenv; + + # Taken from: + # http://www.cs.yale.edu/homes/lucas.paul/posts/2017-04-10-hakyll-on-nix.html + websiteBuilder = pkgs.stdenv.mkDerivation { + name = "website-builder"; + src = ./hakyll; + phases = "unpackPhase buildPhase"; + buildInputs = [ + (pkgs.haskellPackages.ghcWithPackages (p: with p; [ hakyll ])) + ]; + buildPhase = '' + mkdir -p $out/bin + ghc -O2 -dynamic --make Main.hs -o $out/bin/generate-site + ''; + }; +in rec { + euandrehWebsite = stdenv.mkDerivation rec { + name = "euandreh-website"; + src = ./site; + phases = "unpackPhase buildPhase"; + # version = "0.1"; + buildInputs = [ websiteBuilder ]; + buildPhase = '' + export LOCALE_ARCHIVE="${pkgs.glibcLocales}/lib/locale/locale-archive"; + export LANG=en_US.UTF-8 + generate-site build + + mkdir $out + cp -r _site/* $out + ''; + }; +} +``` diff --git a/src/content/pastebins/2018/07/25/nix-showdrv.adoc b/src/content/pastebins/2018/07/25/nix-showdrv.adoc new file mode 100644 index 0000000..813965d --- /dev/null +++ b/src/content/pastebins/2018/07/25/nix-showdrv.adoc @@ -0,0 +1,86 @@ +--- + +title: nix show-derivation sample output + +date: 2018-07-25 + +layout: post + +lang: en + +eu_categories: nix + +ref: nix-show-derivation-sample-output + +--- + +```nix +$ nix show-derivation /nix/store/zzz9cl2ly0mb2njr7vwa5528fxmn29m8-combofont-0.2.drv +{ + "/nix/store/zzz9cl2ly0mb2njr7vwa5528fxmn29m8-combofont-0.2.drv": { + "outputs": { + "out": { + "path": "/nix/store/dc897j29s5pl5mcw064n5b07bydacfm5-combofont-0.2", + "hashAlgo": "r:sha1", + "hash": "06be9cab7176fe6d99dd773315d9ec5c62f6a71b" + } + }, + "inputSrcs": [ + "/nix/store/b6ill8amfg0gki49zapm4asrrw9zzgz9-builder.sh" + ], + "inputDrvs": { + "/nix/store/3s0crp8826gwvfap6kjjyh9a7wq92awk-stdenv.drv": [ + "out" + ], + "/nix/store/fafsh2hx1xxqgm8gwkj3bw3czz6dcvvw-mirrors-list.drv": [ + "out" + ], + "/nix/store/qqla9sd8p8qwgl2a1wpn75bwp2vw70mm-bash-4.4-p12.drv": [ + "out" + ], + "/nix/store/v8fxvb0wlsa5pmrfawa3dg501mglw43c-curl-7.59.0.drv": [ + "dev" + ] + }, + "platform": "x86_64-linux", + "builder": "/nix/store/lw7xaqhakk0i1c631m3cvac3x4lc5gr5-bash-4.4-p12/bin/bash", + "args": [ + "-e", + "/nix/store/b6ill8amfg0gki49zapm4asrrw9zzgz9-builder.sh" + ], + "env": { + "buildInputs": "", + "builder": "/nix/store/lw7xaqhakk0i1c631m3cvac3x4lc5gr5-bash-4.4-p12/bin/bash", + "configureFlags": "", + "curlOpts": "", + "depsBuildBuild": "", + "depsBuildBuildPropagated": "", + "depsBuildTarget": "", + "depsBuildTargetPropagated": "", + "depsHostBuild": "", + "depsHostBuildPropagated": "", + "depsTargetTarget": "", + "depsTargetTargetPropagated": "", + "downloadToTemp": "1", + "executable": "", + "impureEnvVars": "http_proxy https_proxy ftp_proxy all_proxy no_proxy NIX_CURL_FLAGS NIX_HASHED_MIRRORS NIX_CONNECT_TIMEOUT NIX_MIRRORS_apache NIX_MIRRORS_bioc NIX_MIRRORS_bitlbee NIX_MIRRORS_cpan NIX_MIRRORS_debian NIX_MIRRORS_fedora NIX_MIRRORS_gcc NIX_MIRRORS_gentoo NIX_MIRRORS_gnome NIX_MIRRORS_gnu NIX_MIRRORS_gnupg NIX_MIRRORS_hackage NIX_MIRRORS_hashedMirrors NIX_MIRRORS_imagemagick NIX_MIRRORS_kde NIX_MIRRORS_kernel NIX_MIRRORS_maven NIX_MIRRORS_metalab NIX_MIRRORS_mozilla NIX_MIRRORS_mysql NIX_MIRRORS_oldsuse NIX_MIRRORS_openbsd NIX_MIRRORS_opensuse NIX_MIRRORS_postgresql NIX_MIRRORS_pypi NIX_MIRRORS_roy NIX_MIRRORS_sagemath NIX_MIRRORS_samba NIX_MIRRORS_savannah NIX_MIRRORS_sourceforge NIX_MIRRORS_sourceforgejp NIX_MIRRORS_steamrt NIX_MIRRORS_ubuntu NIX_MIRRORS_xfce NIX_MIRRORS_xorg", + "mirrorsFile": "/nix/store/36pk3fz566c2zj6bj8qy7gxl1z14xc4f-mirrors-list", + "name": "combofont-0.2", + "nativeBuildInputs": "/nix/store/hgv54iw72sgpqmzgv30s6gsfc4rd4wzp-curl-7.59.0-dev", + "out": "/nix/store/dc897j29s5pl5mcw064n5b07bydacfm5-combofont-0.2", + "outputHash": "3fkzcqjwxkciacvpvncnvzknf6mrrgh6", + "outputHashAlgo": "sha1", + "outputHashMode": "recursive", + "postFetch": "mkdir \"$out\";tar -xf $downloadedFile \\\n '--strip-components=0' \\\n -C \"$out\" --anchored --exclude=tlpkg --keep-old-files\n", + "preferHashedMirrors": "1", + "preferLocalBuild": "1", + "propagatedBuildInputs": "", + "propagatedNativeBuildInputs": "", + "showURLs": "", + "stdenv": "/nix/store/i3kgk0nibrbpgmzdwdfi2ym50i8m3lww-stdenv", + "system": "x86_64-linux", + "urls": "http://146.185.144.154/texlive-2017/combofont.tar.xz http://gateway.ipfs.io/ipfs/QmRLK45EC828vGXv5YDaBsJBj2LjMjjA2ReLVrXsasRzy7/texlive-2017/combofont.tar.xz" + } + } +} +``` -- cgit v1.2.3