diff --git a/pkgs/systemconfig/default.nix b/pkgs/systemconfig/default.nix index 3f675fa..8b40af0 100644 --- a/pkgs/systemconfig/default.nix +++ b/pkgs/systemconfig/default.nix @@ -28,8 +28,6 @@ let , uid ? 0 , gid ? 0 }: - assert uid == 0; - assert gid == 0; let pathname = "${prefix}/${filename}"; qpathname = builtins.toJSON pathname; @@ -49,7 +47,10 @@ let "i" = "MKNOD_P(${qpathname}, ${mode'});"; }; cmd = cmds.${type}; - in "${cmd}"; + chown = if uid>0 || gid>0 + then "\nCHOWN(${qpathname},${toString uid},${toString gid});\n" + else ""; + in "${cmd} ${chown}"; in mapAttrsToList (makeFile prefix) attrset; activateScript = attrset: writeText "makedevs.c" '' #include "defs.h" @@ -72,6 +73,6 @@ in attrset: makeFlags = ["makedevs"]; installPhase = '' mkdir -p $out/bin - $STRIP --remove-section=.note --remove-section=.comment --strip-all makedevs -o $out/bin/activate + $STRIP --remove-section=.note --remove-section=.comment --strip-all makedevs -o $out/bin/activate ''; } diff --git a/pkgs/systemconfig/defs.h b/pkgs/systemconfig/defs.h index 5b7094f..5a40cc6 100644 --- a/pkgs/systemconfig/defs.h +++ b/pkgs/systemconfig/defs.h @@ -35,3 +35,4 @@ void print_file(char * path, mode_t mode, char * text) { #define LN_S(target, path) (void)symlink(target, path) #define LN(target, path) link(target, path) #define MKNOD_P(path, mode) mkfifo(path, mode) +#define CHOWN(path, uid, gid) chown(path, uid, gid) diff --git a/tests/jffs2/configuration.nix b/tests/jffs2/configuration.nix index 1404579..608822d 100644 --- a/tests/jffs2/configuration.nix +++ b/tests/jffs2/configuration.nix @@ -1,8 +1,19 @@ { config, pkgs, lib, ... } : -{ +let + inherit (pkgs.pseudofile) dir symlink; +in { imports = [ ../../vanilla-configuration.nix + ../../modules/squashfs.nix ../../modules/jffs2.nix ]; config.rootfsType = "jffs2"; + config.filesystem = dir { + hello = { + type = "f"; + uid = 7; + gid = 24; + file = "hello world"; + }; + }; }