aboutsummaryrefslogblamecommitdiff
path: root/_pastebins/2018-07-13-guix-users-in-nixos-system-configuration.md
blob: f7c8440508a71e7490f1e2f9897899e3dc3245e1 (plain) (tree)











































                                                                                                                    
---
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";
    };
  };
```