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)
|
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 {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
21
base.nix.go
21
base.nix.go
@ -1,6 +1,12 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
var base_nix = []byte(`
|
import (
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
"os/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
var base_nix = `
|
||||||
{pkgs, ...}:
|
{pkgs, ...}:
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
@ -24,6 +30,7 @@ var base_nix = []byte(`
|
|||||||
services.spice-vdagentd.enable = true;
|
services.spice-vdagentd.enable = true;
|
||||||
|
|
||||||
users.extraUsers.user = {
|
users.extraUsers.user = {
|
||||||
|
uid = %s;
|
||||||
isNormalUser = true;
|
isNormalUser = true;
|
||||||
extraGroups = [ "audio" ];
|
extraGroups = [ "audio" ];
|
||||||
createHome = true;
|
createHome = true;
|
||||||
@ -58,7 +65,7 @@ startup = do
|
|||||||
systemd.services.mount-home-user = {
|
systemd.services.mount-home-user = {
|
||||||
description = "Mount /home/user (crutch)";
|
description = "Mount /home/user (crutch)";
|
||||||
serviceConfig = {
|
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";
|
RemainAfterExit = "yes";
|
||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
User = "root";
|
User = "root";
|
||||||
@ -106,4 +113,12 @@ startup = do
|
|||||||
wantedBy = ["timers.target"];
|
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 New Issue
Block a user