running vm that mostly works

This commit is contained in:
Noah Masur
2025-03-08 18:08:17 -05:00
parent 1b05fa3745
commit cd0b7debd4
15 changed files with 204 additions and 139 deletions

View File

@ -36,9 +36,11 @@ in
# Always clone dotfiles repository if it doesn't exist
cloneDotfiles = config.lib.dag.entryAfter [ "writeBoundary" "loadkey" ] ''
if [ ! -d "${cfg.path}" ]; then
run mkdir --parents $VERBOSE_ARG $(dirname "${cfg.path}")
run ${lib.getExe pkgs.git} clone ${cfg.repo} "${cfg.path}"
if [ -f ~/.ssh/id_ed25519 ]; then
if [ ! -d "${cfg.path}" ]; then
run mkdir --parents $VERBOSE_ARG $(dirname "${cfg.path}")
run ${lib.getExe pkgs.git} clone ${cfg.repo} "${cfg.path}"
fi
fi
'';
};

View File

@ -0,0 +1,40 @@
{
config,
pkgs,
lib,
...
}:
let
cfg = config.nmasur.presets.programs.nix-index;
in
{
options.nmasur.presets.programs.nix-index.enable =
lib.mkEnableOption "nix-index caching for command line";
config = lib.mkIf cfg.enable {
# Provides "command-not-found" options
programs.nix-index = {
enable = true;
enableFishIntegration = true;
};
# Create nix-index if doesn't exist
home.activation.createNixIndex =
let
cacheDir = "${config.xdg.cacheHome}/nix-index";
in
lib.mkIf config.programs.nix-index.enable (
config.lib.dag.entryAfter [ "writeBoundary" ] ''
if [ ! -d ${cacheDir} ]; then
run ${pkgs.nix-index}/bin/nix-index -f ${pkgs.path}
fi
''
);
};
}

View File

@ -90,66 +90,6 @@ in
bind -M default \x11F nix-fzf
'';
# Provides "command-not-found" options
programs.nix-index = {
enable = true;
enableFishIntegration = true;
};
# Create nix-index if doesn't exist
home.activation.createNixIndex =
let
cacheDir = "${config.xdg.cacheHome}/nix-index";
in
lib.mkIf config.programs.nix-index.enable (
config.lib.dag.entryAfter [ "writeBoundary" ] ''
if [ ! -d ${cacheDir} ]; then
$DRY_RUN_CMD ${pkgs.nix-index}/bin/nix-index -f ${pkgs.path}
fi
''
);
nix = {
# Set channel to flake packages, used for nix-shell commands
nixPath = [ "nixpkgs=${pkgs.path}" ];
# For security, only allow specific users
settings.allowed-users = [
"@wheel" # Anyone in the wheel group
config.home.username # The current user
];
# Enable features in Nix commands
extraOptions = ''
experimental-features = nix-command flakes
warn-dirty = false
'';
# Set automatic generation cleanup for home-manager
gc = {
automatic = true;
options = "--delete-older-than 10d";
};
settings = {
# Add community Cachix to binary cache
# Don't use at work because blocked by corporate firewall
builders-use-substitutes = true;
substituters = lib.mkIf (!config.nmasur.profiles.work.enable) [
"https://nix-community.cachix.org"
];
trusted-public-keys = lib.mkIf (!config.nmasur.profiles.work.enable) [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
# Scans and hard links identical files in the store
# Not working with macOS: https://github.com/NixOS/nix/issues/7273
auto-optimise-store = lib.mkIf (!pkgs.stdenv.isDarwin) true;
};
};
};
}

View File

@ -22,12 +22,15 @@ in
if [ ! -d ~/.ssh ]; then
run mkdir --parents $VERBOSE_ARG ~/.ssh/
fi
if [ ! -f ~/.ssh/id_ed25519 ]; then
printf "\nEnter the seed phrase for your SSH key...\n"
printf "\nThen press ^D when complete.\n\n"
mkdir -p ~/.ssh/
${pkgs.melt}/bin/melt restore ~/.ssh/id_ed25519
printf "\n\nContinuing activation.\n\n"
# But only load if using interactive mode
if [[ $- == *i* ]]; then
if [ ! -f ~/.ssh/id_ed25519 ]; then
printf "\nEnter the seed phrase for your SSH key...\n"
printf "\nThen press ^D when complete.\n\n"
mkdir -p ~/.ssh/
${pkgs.melt}/bin/melt restore ~/.ssh/id_ed25519
printf "\n\nContinuing activation.\n\n"
fi
fi
'';
};

View File

@ -0,0 +1,62 @@
{
config,
pkgs,
lib,
...
}:
let
cfg = config.nmasur.presets.services.nix;
in
{
options.nmasur.presets.services.nix.enable = lib.mkEnableOption "Nix settings and presets";
config = lib.mkIf cfg.enable {
nix = {
# Set channel to flake packages, used for nix-shell commands
nixPath = [ "nixpkgs=${pkgs.path}" ];
# For security, only allow specific users
settings.allowed-users = [
"@wheel" # Anyone in the wheel group
config.home.username # The current user
];
# Enable features in Nix commands
extraOptions = ''
experimental-features = nix-command flakes
warn-dirty = false
'';
# Set automatic generation cleanup for home-manager
gc = {
automatic = true;
options = "--delete-older-than 10d";
};
settings = {
# Add community Cachix to binary cache
# Don't use at work because blocked by corporate firewall
builders-use-substitutes = true;
substituters = lib.mkIf (!config.nmasur.profiles.work.enable) [
"https://nix-community.cachix.org"
];
trusted-public-keys = lib.mkIf (!config.nmasur.profiles.work.enable) [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
# Scans and hard links identical files in the store
# Not working with macOS: https://github.com/NixOS/nix/issues/7273
auto-optimise-store = lib.mkIf (!pkgs.stdenv.isDarwin) true;
};
};
};
}

View File

@ -213,6 +213,7 @@ in
label = "%date%";
label-foreground = config.theme.colors.base06;
# format-background = colors.background;
click-right = lib.getExe config.nmasur.presets.services.i3.terminal;
};
"module/power" = {
type = "custom/text";