mirror of
https://github.com/nix-community/nix-on-droid.git
synced 2025-11-08 19:46:07 +01:00
Move id derivation to separate file
This commit is contained in:
parent
a3d4712695
commit
46b782165a
5 changed files with 24 additions and 25 deletions
|
|
@ -15,6 +15,8 @@ let
|
||||||
|
|
||||||
files = callPackage ./files { } // { recurseForDerivations = true; };
|
files = callPackage ./files { } // { recurseForDerivations = true; };
|
||||||
|
|
||||||
|
ids = callPackage ./ids.nix { };
|
||||||
|
|
||||||
nixDirectory = callPackage ./nix-directory.nix { };
|
nixDirectory = callPackage ./nix-directory.nix { };
|
||||||
|
|
||||||
proot = callPackage ./proot.nix { };
|
proot = callPackage ./proot.nix { };
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
# Licensed under GNU Lesser General Public License v3 or later, see COPYING.
|
# Licensed under GNU Lesser General Public License v3 or later, see COPYING.
|
||||||
# Copyright (c) 2019 Alexander Sosedkin and other contributors, see AUTHORS.
|
# Copyright (c) 2019 Alexander Sosedkin and other contributors, see AUTHORS.
|
||||||
|
|
||||||
{ buildPkgs, initialBuild, nixDirectory, nixOnDroidChannelURL, nixpkgsChannelURL }:
|
{ buildPkgs, initialBuild, nixDirectory
|
||||||
|
, nixOnDroidChannelURL, nixpkgsChannelURL
|
||||||
|
, ids }:
|
||||||
|
|
||||||
let
|
let
|
||||||
instDir = "/data/data/com.termux.nix/files/usr";
|
instDir = "/data/data/com.termux.nix/files/usr";
|
||||||
|
|
@ -20,14 +22,13 @@ let
|
||||||
|
|
||||||
callPackage = buildPkgs.lib.callPackageWith (buildPkgs // {
|
callPackage = buildPkgs.lib.callPackageWith (buildPkgs // {
|
||||||
inherit initialBuild instDir packageInfo writeTextDir;
|
inherit initialBuild instDir packageInfo writeTextDir;
|
||||||
inherit groupName userName;
|
inherit groupName userName ids;
|
||||||
inherit shell;
|
inherit shell;
|
||||||
inherit nixOnDroidChannelURL nixpkgsChannelURL;
|
inherit nixOnDroidChannelURL nixpkgsChannelURL;
|
||||||
});
|
});
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
etc-group = callPackage ./etc-group.nix { };
|
etc-group = callPackage ./etc-group.nix { };
|
||||||
|
|
||||||
etc-passwd = callPackage ./etc-passwd.nix { };
|
etc-passwd = callPackage ./etc-passwd.nix { };
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,9 @@
|
||||||
# Licensed under GNU Lesser General Public License v3 or later, see COPYING.
|
# Licensed under GNU Lesser General Public License v3 or later, see COPYING.
|
||||||
# Copyright (c) 2019 Alexander Sosedkin and other contributors, see AUTHORS.
|
# Copyright (c) 2019 Alexander Sosedkin and other contributors, see AUTHORS.
|
||||||
|
|
||||||
{ coreutils, runCommand, writeTextDir, instDir, userName, groupName }:
|
{ writeTextDir, userName, groupName, ids }:
|
||||||
|
|
||||||
let
|
|
||||||
ids = runCommand "ids" {} ''
|
|
||||||
mkdir $out
|
|
||||||
echo -n $(${coreutils}/bin/id -u) > $out/uid
|
|
||||||
echo -n $(${coreutils}/bin/id -g) > $out/gid
|
|
||||||
'';
|
|
||||||
gid = builtins.readFile "${ids}/gid";
|
|
||||||
|
|
||||||
in
|
|
||||||
|
|
||||||
writeTextDir "etc/group" ''
|
writeTextDir "etc/group" ''
|
||||||
root:x:0:
|
root:x:0:
|
||||||
${groupName}:x:${gid}:${userName}
|
${groupName}:x:${(import ids).gid}:${userName}
|
||||||
''
|
''
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,13 @@
|
||||||
# Licensed under GNU Lesser General Public License v3 or later, see COPYING.
|
# Licensed under GNU Lesser General Public License v3 or later, see COPYING.
|
||||||
# Copyright (c) 2019 Alexander Sosedkin and other contributors, see AUTHORS.
|
# Copyright (c) 2019 Alexander Sosedkin and other contributors, see AUTHORS.
|
||||||
|
|
||||||
{ coreutils, runCommand, writeTextDir, instDir, userName, shell }:
|
{ writeTextDir, instDir, userName, shell, ids }:
|
||||||
|
|
||||||
let
|
let
|
||||||
ids = runCommand "ids" {} ''
|
idSet = import ids;
|
||||||
mkdir $out
|
|
||||||
echo -n $(${coreutils}/bin/id -u) > $out/uid
|
|
||||||
echo -n $(${coreutils}/bin/id -g) > $out/gid
|
|
||||||
'';
|
|
||||||
uid = builtins.readFile "${ids}/uid";
|
|
||||||
gid = builtins.readFile "${ids}/gid";
|
|
||||||
in
|
in
|
||||||
|
|
||||||
writeTextDir "etc/passwd" ''
|
writeTextDir "etc/passwd" ''
|
||||||
root:x:0:0:System administrator:${instDir}/root:/bin/sh
|
root:x:0:0:System administrator:${instDir}/root:/bin/sh
|
||||||
${userName}:x:${uid}:${gid}:/data/data/com.termux.nix/files/home:${shell}
|
${userName}:x:${idSet.uid}:${idSet.gid}:/data/data/com.termux.nix/files/home:${shell}
|
||||||
''
|
''
|
||||||
|
|
|
||||||
13
src/pkgs/ids.nix
Normal file
13
src/pkgs/ids.nix
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
# Licensed under GNU Lesser General Public License v3 or later, see COPYING.
|
||||||
|
# Copyright (c) 2019 Alexander Sosedkin and other contributors, see AUTHORS.
|
||||||
|
|
||||||
|
{ buildPkgs }:
|
||||||
|
|
||||||
|
buildPkgs.runCommand "ids.nix" {} ''
|
||||||
|
cat > $out <<EOF
|
||||||
|
{
|
||||||
|
gid = "$(${buildPkgs.coreutils}/bin/id -g)";
|
||||||
|
uid = "$(${buildPkgs.coreutils}/bin/id -u)";
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
''
|
||||||
Loading…
Add table
Add a link
Reference in a new issue