mirror of
https://code.dumpstack.io/tools/appvm.git
synced 2024-11-04 15:33:18 +00:00
User host user id
This commit is contained in:
parent
dad147eb91
commit
2be0f82e4a
2
appvm.go
2
appvm.go
|
@ -430,7 +430,7 @@ func main() {
|
|||
log.Fatal(err)
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(configDir+"/nix/base.nix", base_nix, 0644)
|
||||
err = ioutil.WriteFile(configDir+"/nix/base.nix", baseNix(), 0644)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
|
21
base.nix.go
21
base.nix.go
|
@ -1,6 +1,12 @@
|
|||
package main
|
||||
|
||||
var base_nix = []byte(`
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os/user"
|
||||
)
|
||||
|
||||
var base_nix = `
|
||||
{pkgs, ...}:
|
||||
{
|
||||
imports = [
|
||||
|
@ -24,6 +30,7 @@ var base_nix = []byte(`
|
|||
services.spice-vdagentd.enable = true;
|
||||
|
||||
users.extraUsers.user = {
|
||||
uid = %s;
|
||||
isNormalUser = true;
|
||||
extraGroups = [ "audio" ];
|
||||
createHome = true;
|
||||
|
@ -58,7 +65,7 @@ startup = do
|
|||
systemd.services.mount-home-user = {
|
||||
description = "Mount /home/user (crutch)";
|
||||
serviceConfig = {
|
||||
ExecStart = "/bin/sh -c '/run/current-system/sw/bin/mount -t 9p -o trans=virtio,version=9p2000.L,uid=1000 home /home/user'";
|
||||
ExecStart = "/bin/sh -c '/run/current-system/sw/bin/mount -t 9p -o trans=virtio,version=9p2000.L home /home/user'";
|
||||
RemainAfterExit = "yes";
|
||||
Type = "oneshot";
|
||||
User = "root";
|
||||
|
@ -106,4 +113,12 @@ startup = do
|
|||
wantedBy = ["timers.target"];
|
||||
};
|
||||
}
|
||||
`)
|
||||
`
|
||||
|
||||
func baseNix() []byte {
|
||||
u, err := user.Current()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
return []byte(fmt.Sprintf(base_nix, u.Uid))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue