I am trying to secure my system further. I have a root user and run0 works fine, so I dont need sudo, su or pkexec. I also dont need to do group and user manipulation as a regular user, so this can go too.
Some binaries will have setuid replaced with exact capabilities, I will see what is necessary and what is already included in nixpkgs.
Several issues occured
Setting a value causes an issue as the packges come with a different value by default. I solve this using setuid = "${lib.mkForce false}";
Note that false is not in quotes. But still I get this odd error
building the system configuration...
error:
… while calling the 'head' builtin
at /nix/store/n8gf8yr0571s1ld4nr6dmk143iv3rvmh-source/lib/attrsets.nix:1534:13:
1533| if length values == 1 || pred here (elemAt values 1) (head values) then
1534| head values
| ^
1535| else
… while evaluating the attribute 'value'
at /nix/store/n8gf8yr0571s1ld4nr6dmk143iv3rvmh-source/lib/modules.nix:1086:7:
1085| // {
1086| value = addErrorContext "while evaluating the option `${showOption loc}':" value;
| ^
1087| inherit (res.defsFinal') highestPrio;
… while evaluating the option `system.build.toplevel':
… while evaluating definitions from `/nix/store/n8gf8yr0571s1ld4nr6dmk143iv3rvmh-source/nixos/modules/system/activation/top-level.nix':
… while evaluating the option `security.wrappers.chage.setuid':
… while evaluating definitions from `/nix/store/2aysbqzpp72iipf93l6gvbjypf4nvyqx-source/configuration/modules/security.nix':
(stack trace truncated; use '--show-trace' to show the full, detailed trace)
error: cannot coerce a set to a string: { _type = "override"; content = false; priority = 50; }
lib.mkForce is just a function for leaving a special datatstructure behind which the nixos module system then reacts specially to when it encounters it. What it leaves behind is an attrset with a particular value for the _type attribute, among other things. You’re trying to antiquote this attrset into a string, and nix is rightfully asking what you’re talking about.
Would probably be simpler to set security.wrappers.<name>.enable = false; for a bunch of these. I mean, you don’t want any special privileges on them, so there’s not much point in having the wrappers.
Btw what exactly is a wrapper? Do the binaries still exist without it?
Also, if I only change groups and users with nixos-rebuild, do I need setuid or the wrappers? I assume nix invokes the binaries to do its thing, but it runs as root?