numtide / system-manager

Manage system config using nix on any distro
MIT License
595 stars 15 forks source link

ERROR system_manager] We need root permissions. #98

Open andreyadrian opened 6 days ago

andreyadrian commented 6 days ago

A) Describe the bug Im following the installaton guide, I have added it to my flake, and added the default.nix. And then running it with the command shown: nix run 'github:numtide/system-manager' -- switch --flake '.'

But I get haerin@orangepizero3:~/.config/home-manager$ nix run 'github:numtide/system-manager' -- switch --flake '.' warning: input 'rust-overlay' has an override for a non-existent input 'flake-utils' [2024-06-26T18:43:36Z INFO system_manager::register] Trying flake URI: .#systemConfigs.orangepizero3... warning: Git tree '/home/haerin/.config/home-manager' is dirty [2024-06-26T18:43:37Z INFO system_manager::register] Attribute .#systemConfigs.orangepizero3 not found in flake. [2024-06-26T18:43:37Z INFO system_manager::register] Trying flake URI: .#systemConfigs.default... warning: Git tree '/home/haerin/.config/home-manager' is dirty [2024-06-26T18:43:37Z INFO system_manager::register] Success, using .#systemConfigs.default [2024-06-26T18:43:37Z INFO system_manager::register] Building new system-manager generation... [2024-06-26T18:43:37Z INFO system_manager::register] Running nix build... warning: Git tree '/home/haerin/.config/home-manager' is dirty [2024-06-26T18:43:37Z INFO system_manager::register] Built system-manager profile /nix/store/npin69q4riknxihbk060a9960p0py3jx-system-manager [2024-06-26T18:43:37Z ERROR system_manager] We need root permissions.

What stands to me its the last bit ERROR system_manager] We need root permissions.

B) To Reproduce

Steps to reproduce the behavior:

  1. My current flake.nix:

`{ description = "Home Manager configuration of haerin";

inputs = {

Specify the source of Home Manager and Nixpkgs.

nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";

home-manager = {
  url = "github:nix-community/home-manager";
  inputs.nixpkgs.follows = "nixpkgs";
};

nvchad-config = {
  url = "git+https://codeberg.org/andreyadrian/nvchad-starter";
  flake = false;
};

system-manager = {
  url = "github:numtide/system-manager";
  inputs.nixpkgs.follows = "nixpkgs";
};

};

outputs = { nixpkgs, home-manager, nvchad-config, system-manager,... }: let system = "aarch64-linux"; pkgs = nixpkgs.legacyPackages.${system}; in {

  # 1. This one is for home-manager
  homeConfigurations."haerin" = home-manager.lib.homeManagerConfiguration {

    inherit pkgs;

    # Specify your home configuration modules here, for example,
    # the path to your home.nix.
    modules = [ ./home.nix ];

    # Optionally use extraSpecialArgs
    # to pass through arguments to home.nix
    extraSpecialArgs = {
      nvchadConfig = nvchad-config;
    };

  };

  # 2. This one is for system-manager
  systemConfigs.default = system-manager.lib.makeSystemConfig {

    modules = [ ./default.nix ];

  };

};

} `

  1. My current default.nix (is the default template):

`{ config, lib, pkgs, ... }:

{ config = { system-manager.allowAnyDistro = true; nixpkgs.hostPlatform = "aarch64-linux";

environment = {
  etc = {
    "foo.conf".text = ''
      launch_the_rockets = true
    '';
  };
  systemPackages = [
    pkgs.fd
    pkgs.hello
  ];
};

systemd.services = {
  foo = {
    enable = true;
    serviceConfig = {
      Type = "oneshot";
      RemainAfterExit = true;
    };
    wantedBy = [ "system-manager.target" ];
    script = ''
      ${lib.getBin pkgs.hello}/bin/hello
      echo "We launched the rockets!"
    '';
  };
};

}; } `

C) Expected behavior

To run with no errors, and let me use system-manager to manage services like docker.

D) System information

OS: Armbian (24.8.0-trunk.36) aarch64 ####### Host: OrangePi Zero3 ########### Kernel: 6.6.31-current-sunxi64

E) Additional context

I do have root access but trying sudo nix run 'github:numtide/system-manager' -- switch --flake '.' wont work haerin@orangepizero3:~/.config/home-manager$ sudo nix run 'github:numtide/system-manager' -- switch --flake '.' sudo: nix: command not found

aanderse commented 6 days ago

please clean up formatting of your messages it is too difficult to read as you have posted

r-vdp commented 6 days ago

Yeah so system-manager needs root permissions, as the error says. This is normal, since it will be managing system-level config, which is all owned by root.

Did you try running it with sudo for instance?

andreyadrian commented 6 days ago

Yeah so system-manager needs root permissions, as the error says. This is normal, since it will be managing system-level config, which is all owned by root.

Did you try running it with sudo for instance?

Yeah I'd try with: 'sudo nix run 'github:numtide/system-manager' -- switch --flake '.''

It returns 'sudo: nix: command not found'

aanderse commented 6 days ago

sounds like an Ubuntu issue: https://unix.stackexchange.com/questions/83191/how-to-make-sudo-preserve-path

andreyadrian commented 6 days ago

sounds like an Ubuntu issue: https://unix.stackexchange.com/questions/83191/how-to-make-sudo-preserve-path

Im gonna be trying with this instead then: '$ sudo /nix/var/nix/profiles/default/bin/nix run 'github:numtide/system-manager' -- switch --flake '.''

Thats what i got after running '$ which nix'

Lets see

andreyadrian commented 6 days ago

So this time i got a different error image

`haerin@orangepizero3:~/.config/home-manager$ sudo /nix/var/nix/profiles/default/bin/nix run 'github:numtide/system-manager' -- switch --flake '.' warning: input 'rust-overlay' has an override for a non-existent input 'flake-utils' [2024-06-26T22:23:24Z INFO system_manager::register] Trying flake URI: .#systemConfigs.orangepizero3... error: … while fetching the input 'git+file:///home/haerin/.config/home-manager'

   error: getting the HEAD of the Git tree '/home/haerin/.config/home-manager' failed with exit code 1:
   error: executing 'git': No such file or directory

[2024-06-26T22:23:27Z INFO system_manager::register] Attribute .#systemConfigs.orangepizero3 not found in flake. [2024-06-26T22:23:27Z INFO system_manager::register] Trying flake URI: .#systemConfigs.default... error: … while fetching the input 'git+file:///home/haerin/.config/home-manager'

   error: getting the HEAD of the Git tree '/home/haerin/.config/home-manager' failed with exit code 1:
   error: executing 'git': No such file or directory

[2024-06-26T22:23:27Z INFO system_manager::register] Attribute .#systemConfigs.default not found in flake. [2024-06-26T22:23:27Z ERROR system_manager] No suitable flake attribute found, giving up. haerin@orangepizero3:~/.config/home-manager$`

r-vdp commented 5 days ago

This seems to also have to do with your PATH variable, I think that this is nix who expects git to be provided by the system.

One way to get around this, would be to launch a root shell, and then get a nix shell with everything that nix and system-manager need:

sudo -i
nix-shell -p nix git

But I also think that something is quite broken in your system's setup, I don't think that this is how sudo is usually configured.