Skip to content

Instantly share code, notes, and snippets.

@ciderale
Last active January 14, 2019 19:47
Show Gist options
  • Save ciderale/3a796ff0711c68d4997b013e4e8d0c3d to your computer and use it in GitHub Desktop.
Save ciderale/3a796ff0711c68d4997b013e4e8d0c3d to your computer and use it in GitHub Desktop.
{ user ? "$(whoami)" # or 1234
}:
with import <nixpkgs> {
config = {
packageOverrides = pkgs: {
nix = pkgs.nix.overrideAttrs(oldAttrs: {
prePatch = ''
substituteInPlace src/libstore/local-store.cc \
--replace '(eaName == "security.selinux")' \
'(eaName == "security.selinux" || eaName == "system.nfs4_acl")'
'';
});
};
};
};
let
buildWithAcl = runCommand "buildWithAcl" { buildInputs = [ acl ]; } ''
mkdir $out
date > $out/x;
setfacl -m u:${user}:rwx $out/x;
getfacl $out/x;
'';
expected = writeText "expected" ''
# owner: root
# group: root
user::r--
group::r--
other::r--
'';
in {
inherit nix buildWithAcl expected;
shell = mkShell {
buildInputs = [nix acl];
shellHook = ''
function testacl() {
# nix-shell ./fix-fs-attrs.nix -A shell --command 'testacl'
nix-build --option filter-syscalls false ./fix-fs-attrs.nix -A buildWithAcl \
&& getfacl ./result/x | sed -e 1d > actual \
&& cat actual \
&& echo "ACL Removal:" \
&& diff ${expected} actual && echo "successful" || echo "failed"
}
'';
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment