mirror of
https://github.com/nix-community/nix-on-droid.git
synced 2025-11-08 19:46:07 +01:00
81 lines
1.5 KiB
Nix
81 lines
1.5 KiB
Nix
# Licensed under GNU Lesser General Public License v3 or later, see COPYING.
|
|
# Copyright (c) 2019 Alexander Sosedkin and other contributors, see AUTHORS.
|
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
cfg = config.user;
|
|
|
|
idsDerivation = pkgs.runCommand "ids.nix" {} ''
|
|
cat > $out <<EOF
|
|
{
|
|
gid = "$(${pkgs.coreutils}/bin/id -g)";
|
|
uid = "$(${pkgs.coreutils}/bin/id -u)";
|
|
}
|
|
EOF
|
|
'';
|
|
|
|
ids = import idsDerivation;
|
|
in
|
|
|
|
{
|
|
|
|
###### interface
|
|
|
|
options = {
|
|
|
|
user = {
|
|
group = mkOption {
|
|
type = types.str;
|
|
default = "nix-on-droid";
|
|
description = "Group name.";
|
|
};
|
|
|
|
home = mkOption {
|
|
type = types.path;
|
|
readOnly = true;
|
|
description = "Path to home directory.";
|
|
};
|
|
|
|
shell = mkOption {
|
|
type = types.path;
|
|
readOnly = true;
|
|
description = "Path to login shell.";
|
|
};
|
|
|
|
userName = mkOption {
|
|
type = types.str;
|
|
default = "nix-on-droid";
|
|
description = "User name.";
|
|
};
|
|
};
|
|
|
|
};
|
|
|
|
|
|
###### implementation
|
|
|
|
config = {
|
|
|
|
environment.etc = {
|
|
"group".text = ''
|
|
root:x:0:
|
|
${cfg.group}:x:${ids.gid}:${cfg.userName}
|
|
'';
|
|
|
|
"passwd".text = ''
|
|
root:x:0:0:System administrator:${config.build.installationDir}/root:/bin/sh
|
|
${cfg.userName}:x:${ids.uid}:${ids.gid}:${cfg.userName}:${cfg.home}:${cfg.shell}
|
|
'';
|
|
};
|
|
|
|
user = {
|
|
home = "/data/data/com.termux.nix/files/home";
|
|
shell = "/bin/sh";
|
|
};
|
|
|
|
};
|
|
|
|
}
|