about summary refs log tree commit diff
path: root/users/Profpatsch/nix-home/default.nix
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-01-30T16·06+0300
committertazjin <tazjin@tvl.su>2022-01-31T16·11+0000
commitaa122cbae78ce97d60c0c98ba14df753d97e40b1 (patch)
tree12b98d85c4b18fe870feb26de70db9ba61837bd7 /users/Profpatsch/nix-home/default.nix
parent2d10d60fac0fd00a71b65cfdcb9fba0477b2086c (diff)
style: format entire depot with nixpkgs-fmt r/3723
This CL can be used to compare the style of nixpkgs-fmt against other
formatters (nixpkgs, alejandra).

Change-Id: I87c6abff6bcb546b02ead15ad0405f81e01b6d9e
Reviewed-on: https://cl.tvl.fyi/c/depot/+/4397
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
Reviewed-by: lukegb <lukegb@tvl.fyi>
Reviewed-by: wpcarro <wpcarro@gmail.com>
Reviewed-by: Profpatsch <mail@profpatsch.de>
Reviewed-by: kanepyork <rikingcoding@gmail.com>
Reviewed-by: tazjin <tazjin@tvl.su>
Reviewed-by: cynthia <cynthia@tvl.fyi>
Reviewed-by: edef <edef@edef.eu>
Reviewed-by: eta <tvl@eta.st>
Reviewed-by: grfn <grfn@gws.fyi>
Diffstat (limited to 'users/Profpatsch/nix-home/default.nix')
-rw-r--r--users/Profpatsch/nix-home/default.nix180
1 files changed, 114 insertions, 66 deletions
diff --git a/users/Profpatsch/nix-home/default.nix b/users/Profpatsch/nix-home/default.nix
index cf9ab0d4d4..8f52055ade 100644
--- a/users/Profpatsch/nix-home/default.nix
+++ b/users/Profpatsch/nix-home/default.nix
@@ -2,97 +2,145 @@
 
 let
   bins = depot.nix.getBins pkgs.stow [ "stow" ]
-      // depot.nix.getBins pkgs.coreutils [ "mkdir" "ln" "printenv" "rm" ]
-      // depot.nix.getBins pkgs.xe [ "xe" ]
-      // depot.nix.getBins pkgs.lr [ "lr" ]
-      // depot.nix.getBins pkgs.nix [ "nix-store" ]
-      ;
+    // depot.nix.getBins pkgs.coreutils [ "mkdir" "ln" "printenv" "rm" ]
+    // depot.nix.getBins pkgs.xe [ "xe" ]
+    // depot.nix.getBins pkgs.lr [ "lr" ]
+    // depot.nix.getBins pkgs.nix [ "nix-store" ]
+  ;
 
   # run stow to populate the target directory with the given stow package, read from stowDir.
   # Bear in mind that `stowDirOriginPath` should always be semantically bound to the given `stowDir`, otherwise stow might become rather confused.
-  runStow = {
-    # “stow package” to stow (see manpage)
-    stowPackage,
-    # “target directory” to stow in (see manpage)
-    targetDir,
-    # The “stow directory” (see manpage), containing “stow packages” (see manpage)
-    stowDir,
-    # representative directory for the stowDir in the file system, against which stow will create relative links.
-    # ATTN: this is always overwritten with the contents of `stowDir`! You shouldn’t re-use the same `stowDirOriginPath` for different `stowDir`s, otherwise there might be surprises.
-    stowDirOriginPath,
-  }: depot.nix.writeExecline "stow-${stowPackage}" {} [
-    # first, create a temporary stow directory to use as source
-    # (stow will use it to determine the origin of files)
-    "if" [ bins.mkdir "-p" stowDirOriginPath ]
-    # remove old symlinks
-    "if" [
-      "pipeline" [
-        bins.lr "-0" "-t" "depth == 1 && type == l" stowDirOriginPath
+  runStow =
+    {
+      # “stow package” to stow (see manpage)
+      stowPackage
+    , # “target directory” to stow in (see manpage)
+      targetDir
+    , # The “stow directory” (see manpage), containing “stow packages” (see manpage)
+      stowDir
+    , # representative directory for the stowDir in the file system, against which stow will create relative links.
+      # ATTN: this is always overwritten with the contents of `stowDir`! You shouldn’t re-use the same `stowDirOriginPath` for different `stowDir`s, otherwise there might be surprises.
+      stowDirOriginPath
+    ,
+    }: depot.nix.writeExecline "stow-${stowPackage}" { } [
+      # first, create a temporary stow directory to use as source
+      # (stow will use it to determine the origin of files)
+      "if"
+      [ bins.mkdir "-p" stowDirOriginPath ]
+      # remove old symlinks
+      "if"
+      [
+        "pipeline"
+        [
+          bins.lr
+          "-0"
+          "-t"
+          "depth == 1 && type == l"
+          stowDirOriginPath
+        ]
+        bins.xe
+        "-0"
+        bins.rm
       ]
-      bins.xe "-0" bins.rm
-    ]
-    # create an indirect gc root so our config is not cleaned under our asses by a garbage collect
-    "if" [
-      bins.nix-store
+      # create an indirect gc root so our config is not cleaned under our asses by a garbage collect
+      "if"
+      [
+        bins.nix-store
         "--realise"
         "--indirect"
-        "--add-root" "${stowDirOriginPath}/.nix-stowdir-gc-root"
+        "--add-root"
+        "${stowDirOriginPath}/.nix-stowdir-gc-root"
         stowDir
-    ]
-    # populate with new stow targets
-    "if" [
-      "elglob" "-w0" "stowPackages" "${stowDir}/*"
-      bins.ln "--force" "-st" stowDirOriginPath "$stowPackages"
-    ]
-    # stow always looks for $HOME/.stowrc to read more arguments
-    "export" "HOME" "/homeless-shelter"
-    bins.stow
+      ]
+      # populate with new stow targets
+      "if"
+      [
+        "elglob"
+        "-w0"
+        "stowPackages"
+        "${stowDir}/*"
+        bins.ln
+        "--force"
+        "-st"
+        stowDirOriginPath
+        "$stowPackages"
+      ]
+      # stow always looks for $HOME/.stowrc to read more arguments
+      "export"
+      "HOME"
+      "/homeless-shelter"
+      bins.stow
       # always run restow for now; this does more stat but will remove stale links
       "--restow"
-      "--dir" stowDirOriginPath
-      "--target" targetDir
+      "--dir"
+      stowDirOriginPath
+      "--target"
+      targetDir
       stowPackage
-  ];
+    ];
 
   # create a stow dir from a list of drv paths and a stow package name.
   makeStowDir =
     (with depot.nix.yants;
-     defun
-       [ (list (struct {
+    defun
+      [
+        (list (struct {
           originalDir = drv;
           stowPackage = string;
         }))
         drv
-       ] )
-    (dirs:
-      depot.nix.runExecline "make-stow-dir" {
-        stdin = lib.pipe dirs [
-          (map depot.users.Profpatsch.netencode.gen.dwim)
-          depot.users.Profpatsch.netstring.toNetstringList
-        ];
-      } [
-        "importas" "out" "out"
-        "if" [ bins.mkdir "-p" "$out" ]
-        "forstdin" "-d" "" "-o" "0" "line"
-        "pipeline" [
-          depot.users.Profpatsch.execline.print-one-env "line"
-        ]
-        depot.users.Profpatsch.netencode.record-splice-env
-        "importas" "-ui" "originalDir" "originalDir"
-        "importas" "-ui" "stowPackage" "stowPackage"
-        bins.ln "-sT" "$originalDir" "\${out}/\${stowPackage}"
-      ]);
+      ])
+      (dirs:
+        depot.nix.runExecline "make-stow-dir"
+          {
+            stdin = lib.pipe dirs [
+              (map depot.users.Profpatsch.netencode.gen.dwim)
+              depot.users.Profpatsch.netstring.toNetstringList
+            ];
+          } [
+          "importas"
+          "out"
+          "out"
+          "if"
+          [ bins.mkdir "-p" "$out" ]
+          "forstdin"
+          "-d"
+          ""
+          "-o"
+          "0"
+          "line"
+          "pipeline"
+          [
+            depot.users.Profpatsch.execline.print-one-env
+            "line"
+          ]
+          depot.users.Profpatsch.netencode.record-splice-env
+          "importas"
+          "-ui"
+          "originalDir"
+          "originalDir"
+          "importas"
+          "-ui"
+          "stowPackage"
+          "stowPackage"
+          bins.ln
+          "-sT"
+          "$originalDir"
+          "\${out}/\${stowPackage}"
+        ]);
 
 in
 
 # TODO: temp setup
-lib.pipe {} [
+lib.pipe { } [
   (_: makeStowDir [{
     stowPackage = "scripts";
     originalDir = pkgs.linkFarm "scripts-farm" [
-        { name = "scripts/ytextr";
-          path = depot.users.Profpatsch.ytextr; }
-      ];
+      {
+        name = "scripts/ytextr";
+        path = depot.users.Profpatsch.ytextr;
+      }
+    ];
   }])
   (d: runStow {
     stowDir = d;