mirror of
https://github.com/nix-community/nix-on-droid.git
synced 2025-11-08 11:36:07 +01:00
Add modules
This commit is contained in:
parent
5cc656fffc
commit
f40362898a
19 changed files with 1045 additions and 0 deletions
81
modules/user.nix
Normal file
81
modules/user.nix
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
# 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";
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue