Skip to content

Commit

Permalink
feat: keyring.nix
Browse files Browse the repository at this point in the history
Use commit instead of version as git ref for the codchi driver
  • Loading branch information
htngr committed Nov 22, 2024
1 parent a410d0a commit 9f6be1e
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 9 deletions.
2 changes: 1 addition & 1 deletion codchi/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::{
pub const APP_NAME: &str = "codchi";

pub static GIT_BRANCH: &str = env!("CODCHI_GIT_BRANCH");
pub static CODCHI_FLAKE_URL: &str = concat!("github:aformatik/codchi/", env!("CODCHI_GIT_BRANCH"));
pub static CODCHI_FLAKE_URL: &str = concat!("github:aformatik/codchi/", env!("CODCHI_GIT_COMMIT"));

pub const CONTAINER_STORE_NAME: &str = "codchistore";

Expand Down
40 changes: 36 additions & 4 deletions codchi/src/platform/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,43 @@ tail -f "{log_file}"
}

fn create_exec_cmd(&self, cmd: &[&str]) -> super::LinuxCommandBuilder {
let args = [&[consts::user::DEFAULT_NAME], cmd].concat();
let cmd = self.cmd().raw("su", &args);
// let args = [&[consts::user::DEFAULT_NAME], cmd].concat();
let cmd = if cmd.is_empty() {
self.cmd().raw(
"machinectl",
&[
&[
"shell",
"-q",
"-E",
"DISPLAY",
"-E",
"XAUTHORITY",
&format!("{}@", consts::user::DEFAULT_NAME),
],
cmd,
]
.concat(),
)
} else {
self.cmd().raw(
"machinectl",
&[
"shell",
"-q",
"-E",
"DISPLAY",
"-E",
"XAUTHORITY",
&format!("{}@", consts::user::DEFAULT_NAME),
"/bin/bash",
"-c",
&cmd.join(" "),
],
)
};

cmd.with_cwd(consts::user::DEFAULT_HOME.clone())
.with_user(LinuxUser::Root)
cmd.with_user(LinuxUser::Root)
}
}

Expand Down
6 changes: 2 additions & 4 deletions nix/container/pkgs/make-tarball.nix
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,14 @@ let
# Copy relative symlinks as is
for f in $rel_links; do
mkdir -p "$(dirname "$f")"
[ -e "$f" ] && rm -f "$f"
cp -af "$pkg/$f" "$f"
cp -af "$pkg/$f" "$f" || true # file might already exist
echo "$f" >> .files
done
# Copy files and derefenrence absolute symlinks as is
for f in $files; do
mkdir -p "$(dirname "$f")"
[ -e "$f" ] && rm -f "$f"
cp -afL "$pkg/$f" "$f"
cp -afL "$pkg/$f" "$f" || true # file might already exist
echo "$f" >> .files
done
done
Expand Down
1 change: 1 addition & 0 deletions nix/nixos/modules/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
./recommended-config.nix
./java.nix
./docker.nix
./keyring.nix
];
}
23 changes: 23 additions & 0 deletions nix/nixos/modules/keyring.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{ config, lib, pkgs, ... }:
let
cfg = config.codchi.keyring;
in
{
options.codchi.keyring = {
enable = lib.mkEnableOption "a keyring for applications like IntelliJ";
};

config = lib.mkIf cfg.enable {

services.gnome.gnome-keyring.enable = true;

systemd.user.services.gnome-keyring = {
wantedBy = [ "default.target" ];
serviceConfig = {
ExecStart =
"${pkgs.gnome.gnome-keyring}/bin/gnome-keyring-daemon --start --foreground --components=pkcs11,secrets,ssh";
Restart = "on-abort";
};
};
};
}
1 change: 1 addition & 0 deletions nix/nixos/modules/recommended-config.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ in
// { default = true; };

config = mkIf config.codchi.enableRecommendedConfig {
codchi.keyring.enable = true;
environment.systemPackages = with pkgs; [
vim
git
Expand Down

0 comments on commit 9f6be1e

Please sign in to comment.