blob: a48467193bd9b300a7a822cda777b17df5f571df (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# Lix should be able to build derivations that want working NSS, even with
# broken user namespaces support
{ ... }:
let
testDerivation = builtins.toFile "test.nix" ''
{ cacheBreak }:
let pkgs = import <nixpkgs> { };
in
pkgs.runCommand "test" { } '''
# ''${cacheBreak}
id -g
id -u
echo "GROUP"
cat /etc/group
echo "PASSWD"
cat /etc/passwd
username=$(id -un)
groupname=$(id -gn)
[[ "$username" =~ nixbld* ]]
[[ "$groupname" =~ nixbld* ]]
touch $out
'''
'';
in
{
name = "broken-userns";
nodes.machine =
{
config,
lib,
pkgs,
...
}:
{
virtualisation.writableStore = true;
nix.settings.substituters = lib.mkForce [ ];
nix.nixPath = [ "nixpkgs=${lib.cleanSource pkgs.path}" ];
virtualisation.additionalPaths = [
pkgs.stdenvNoCC
testDerivation
];
};
testScript =
{ nodes }:
''
start_all()
# Building it normally should work
machine.succeed(r"""
nix-build --argstr cacheBreak 1 --store daemon ${testDerivation}
""")
# Building it with broken userns should also work
machine.succeed(r"""
# break user ns
sysctl -w user.max_user_namespaces=0
""")
machine.systemctl("restart nix-daemon")
machine.succeed(r"""
nix-build --argstr cacheBreak 2 --store daemon ${testDerivation}
""")
'';
}
|