Skip to content

Commit 61944d7

Browse files
authored
Merge pull request #290 from numtide/sudo-v2
--sudo v2
2 parents 4ae3158 + 3236855 commit 61944d7

File tree

22 files changed

+860
-213
lines changed

22 files changed

+860
-213
lines changed

Cargo.lock

Lines changed: 43 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,17 @@
1-
[package]
2-
name = "system_manager"
1+
[workspace]
2+
resolver = "2"
3+
members = [
4+
"crates/system-manager-engine",
5+
"crates/system-manager",
6+
]
7+
8+
[workspace.package]
39
version = "0.1.0"
410
edition = "2021"
511
license = "MIT"
6-
authors = [
7-
"Ramses <ramses@well-founded.dev>"
8-
]
9-
10-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
11-
12-
[[bin]]
13-
name = "system-manager"
14-
path = "src/main.rs"
15-
16-
[profile.release]
17-
lto = true
18-
codegen-units = 1
19-
panic = "abort"
12+
authors = ["Ramses <ramses@well-founded.dev>"]
2013

21-
[dependencies]
14+
[workspace.dependencies]
2215
anyhow = "1.0.68"
2316
clap = { version = "4.1.4", features = ["derive"] }
2417
dbus = "0.9.7"
@@ -28,6 +21,15 @@ itertools = "0.14.0"
2821
log = "0.4.17"
2922
nix = { version = "0.30.0", features = ["hostname", "user"] }
3023
regex = "1.11.1"
24+
rpassword = "7.3.1"
3125
serde = { version = "1.0.152", features = ["derive"] }
3226
serde_json = "1.0.91"
3327
thiserror = "2.0.0"
28+
29+
# Internal crates
30+
system-manager-engine = { path = "crates/system-manager-engine" }
31+
32+
[profile.release]
33+
lto = true
34+
codegen-units = 1
35+
panic = "abort"

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,18 +124,18 @@ Create a file in the same folder called `cli_tools.nix` and add the following in
124124
125125
```
126126

127-
This specifies a configuration that includes `btop` and `bat` to be installed on the system. To do so, execute System Manager with `sudo` using the nix command (assuming you have experimental features nix-command and flakes turned on):
127+
This specifies a configuration that includes `btop` and `bat` to be installed on the system. To do so, execute System Manager with the `--sudo` flag (assuming you have experimental features nix-command and flakes turned on):
128128

129129
```
130-
sudo env PATH="$PATH" nix run 'github:numtide/system-manager' -- switch --flake .
130+
nix run 'github:numtide/system-manager' -- switch --sudo --flake .
131131
```
132132

133-
Notice we're passing the current `PATH` environment into `sudo` so that the elevated shell can locate the `nix` command.
133+
The `--sudo` flag tells system-manager to use sudo for privileged operations (activating the configuration).
134134

135135
Also, note that you might need to enable `nix-commands` and `flakes` if you don't already have them set:
136136

137137
```
138-
sudo env PATH="$PATH" nix --extra-experimental-features 'nix-command flakes' run 'github:numtide/system-manager' -- switch --flake .
138+
nix --extra-experimental-features 'nix-command flakes' run 'github:numtide/system-manager' -- switch --sudo --flake .
139139
```
140140

141141
> [!Note]
@@ -308,7 +308,7 @@ Then create the file called `say_hello.nix` and add the following to it:
308308
Activate it using the same nix command as earlier:
309309

310310
```
311-
sudo env PATH="$PATH" nix run 'github:numtide/system-manager' -- switch --flake .
311+
nix run 'github:numtide/system-manager' -- switch --sudo --flake .
312312
```
313313

314314
This will create a system service called `say-hello` (which comes from the line `config.systemd.services.say-hello`) in a unit file at `/etc/systemd/system/say-hello.service` with the following inside it:
@@ -418,7 +418,7 @@ Then, create the `sample_etc.nix` file with the following into it:
418418
Run it as usual, and you should see the file now exists:
419419

420420
```
421-
sudo env PATH="$PATH" nix run 'github:numtide/system-manager' -- switch --flake .
421+
nix run 'github:numtide/system-manager' -- switch --sudo --flake .
422422
423423
ls /etc -ltr
424424
```
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[package]
2+
name = "system-manager-engine"
3+
version.workspace = true
4+
edition.workspace = true
5+
license.workspace = true
6+
authors.workspace = true
7+
description = "Engine for managing system configuration (etc files, systemd services)"
8+
9+
[lib]
10+
name = "system_manager_engine"
11+
path = "src/lib.rs"
12+
13+
[[bin]]
14+
name = "system-manager-engine"
15+
path = "src/main.rs"
16+
17+
[dependencies]
18+
anyhow.workspace = true
19+
clap.workspace = true
20+
dbus.workspace = true
21+
env_logger.workspace = true
22+
im.workspace = true
23+
itertools.workspace = true
24+
log.workspace = true
25+
nix.workspace = true
26+
regex.workspace = true
27+
serde.workspace = true
28+
serde_json.workspace = true
29+
thiserror.workspace = true

src/activate.rs renamed to crates/system-manager-engine/src/activate.rs

File renamed without changes.

src/activate/etc_files.rs renamed to crates/system-manager-engine/src/activate/etc_files.rs

File renamed without changes.

src/activate/etc_files/etc_tree.rs renamed to crates/system-manager-engine/src/activate/etc_files/etc_tree.rs

File renamed without changes.

src/activate/services.rs renamed to crates/system-manager-engine/src/activate/services.rs

File renamed without changes.

src/activate/tmp_files.rs renamed to crates/system-manager-engine/src/activate/tmp_files.rs

File renamed without changes.

0 commit comments

Comments
 (0)