nix machine / user configurations

feat(dusk@devel.mobi): init user for devbox [skip ci]

ptr.pet f2f4317d 14270326

verified
Changed files
+212 -109
hosts
wolumonde
modules
modules
users
+7 -3
commit.nu
···
if $val == null { do $block } else { $val }
}
+
def get-attr-keys [attr: string] {
+
nix eval $attr --apply builtins.attrNames --json --quiet | from json
+
}
def main [
_msg?: string
···
let msg: string = unwrap-or-else $_msg { input 'enter commit message: ' }
let types = ["feat" "build" "ci" "fix" "refactor" "chore" "style"]
-
let hosts: list<string> = (nix eval ".#nixosConfigurations" --apply builtins.attrNames --json --quiet | from json)
-
let scopes = $hosts ++ ["qol" "treewide" "deploy" "commit" "deps"]
+
let hosts: list<string> = (get-attr-keys ".#nixosConfigurations")
+
let users: list<string> = (get-attr-keys ".#homeConfigurations")
+
let scopes = $hosts ++ $users ++ ["qol" "treewide" "deploy" "commit" "deps"]
let ty: string = unwrap-or-else $type { $types | input list 'choose type' --fuzzy }
let scp: string = unwrap-or-else $scope { $scopes | input list 'choose scope' --fuzzy }
let skipci = if not $skip_ci { "" } else { " [skip ci]" }
let commit_msg = $"($ty)\(($scp)\): ($msg)($skipci)"
git commit -m $commit_msg ...$rest
-
}
+
}
+36 -14
deploy.nu
···
return {result: $result, elapsed: ($end - $start)}
}
-
let ips = {
-
wolumonde: "23.88.101.188",
+
let hosts = {
+
wolumonde: {
+
type: "nixos",
+
user: "root",
+
addr: "23.88.101.188",
+
},
+
"dusk@devel.mobi": {
+
type: "home",
+
user: "dusk",
+
addr: "devel.mobi",
+
},
}
def deploy [hostname: string] {
log info $"start deploy host ($hostname)"
let hooktitle = $"/($hostname)/deploy"
+
let hostcfg = $hosts | get $hostname
webhook $hooktitle $"=== deploy for ($hostname): started ===\n\n(sys disks | to text)\n\n(sys mem | to text)"
···
}
let result_dir = mktemp -d | path join "result"
-
let build_cmd = {nh os build --no-nom -H $hostname -o $result_dir -- -L --show-trace}
+
let build_cmd = {
+
match $hostcfg.type {
+
"nixos" => {nh os build --no-nom -H $hostname -o $result_dir -- -L --show-trace}
+
"home" => {nh home build --no-nom -c $hostname -o $result_dir -- -L --show-trace}
+
}
+
}
if (run_step "build" $build_cmd) {
return
}
let result_link = readlink $result_dir
-
# TODO: dont hardcode user
-
let target = $"root@($ips | get $hostname)"
+
let target = $"($hostcfg.user)@($hostcfg.addr)"
let copy_cmd = {nix copy --to $"ssh://($target)" $result_link}
if (run_step "copy to" $copy_cmd) {
return
}
-
let activate_cmd = {ssh $target $"sudo '($result_link)/bin/switch-to-configuration' 'switch'"}
+
let activate_cmd = {
+
let cmd = match $hostcfg.type {
+
"nixos" => $"sudo '($result_link)/bin/switch-to-configuration' 'switch'",
+
"home" => $"($result_link)/activate",
+
}
+
ssh $target $cmd
+
}
if (run_step "activate" $activate_cmd) {
return
}
···
}
}
-
def main [hostname: string = "wolumonde"] {
+
def main [hostname: string = "wolumonde", --only-deploy (-d)] {
webhook "deploy" "=== started deploying all ==="
-
["blog" "limbusart" "nsid-tracker"]
-
| each {|input| update-input $input}
+
if $only_deploy == false {
+
["blog" "limbusart" "nsid-tracker"]
+
| each {|input| update-input $input}
-
try {
-
log info "trying to update dns records"
-
nix run ".#dns" -- push
-
} catch { |err|
-
webhook "dns" $"=== error pushing dns ===\n\n($err.msg | to text)" 1
+
try {
+
log info "trying to update dns records"
+
nix run ".#dns" -- push
+
} catch { |err|
+
webhook "dns" $"=== error pushing dns ===\n\n($err.msg | to text)" 1
+
}
}
deploy $hostname
+1 -1
flake.nix
···
{
lib = tlib;
nixosConfigurations = import ./hosts { inherit lib tlib inputs; };
-
homeConfigurations = import ./users;
+
homeConfigurations = import ./users { inherit lib tlib inputs; };
packages = lib.mapAttrs (_: pkgs: pkgs._exported) allPkgs;
legacyPackages = allPkgs;
-1
hosts/wolumonde/modules/nushell.nix
···
-
../../../modules/nushell/default.nix
-82
modules/nushell/default.nix
···
-
{ lib, pkgs, ... }:
-
{
-
environment.shells = [ pkgs.nushell ];
-
users.users.root.shell = pkgs.nushell;
-
-
home-manager.users.root = {
-
programs.nushell = {
-
enable = true;
-
package = pkgs.nushell;
-
shellAliases = {
-
myip = lib.mkForce "echo";
-
};
-
extraEnv = ''
-
source-env ${./prompt.nu}
-
'';
-
extraConfig = ''
-
let carapace_completer = {|spans: list<string>|
-
carapace $spans.0 nushell ...$spans
-
| from json
-
| if ($in | default [] | where value == $"($spans | last)ERR" | is-empty) { $in } else { null }
-
}
-
$env.CARAPACE_BRIDGES = 'zsh,fish,bash,inshellisense'
-
-
let fish_completer = {|spans|
-
${lib.getExe pkgs.fish} --command $'complete "--do-complete=($spans | str join " ")"'
-
| $"value(char tab)description(char newline)" + $in
-
| from tsv --flexible --no-infer
-
}
-
-
let zoxide_completer = {|spans|
-
$spans | skip 1 | zoxide query -l ...$in | lines | where {|x| $x != $env.PWD}
-
}
-
-
let multiple_completers = {|spans|
-
## alias fixer start https://www.nushell.sh/cookbook/external_completers.html#alias-completions
-
let expanded_alias = scope aliases
-
| where name == $spans.0
-
| get -i 0.expansion
-
-
let spans = if $expanded_alias != null {
-
$spans
-
| skip 1
-
| prepend ($expanded_alias | split row ' ' | take 1)
-
} else {
-
$spans
-
}
-
## alias fixer end
-
-
match $spans.0 {
-
__zoxide_z | __zoxide_zi => $zoxide_completer
-
_ => $carapace_completer
-
} | do $in $spans
-
}
-
-
$env.config = {
-
show_banner: false,
-
completions: {
-
case_sensitive: false # case-sensitive completions
-
quick: true # set to false to prevent auto-selecting completions
-
partial: true # set to false to prevent partial filling of the prompt
-
algorithm: "fuzzy" # prefix or fuzzy
-
external: {
-
# set to false to prevent nushell looking into $env.PATH to find more suggestions
-
enable: true
-
# set to lower can improve completion performance at the cost of omitting some options
-
max_results: 100
-
completer: $multiple_completers
-
}
-
}
-
}
-
$env.PATH = ($env.PATH |
-
split row (char esep) |
-
append /usr/bin/env
-
)
-
-
source ${./aliases.nu}
-
'';
-
};
-
programs.carapace.enable = true;
-
programs.carapace.enableNushellIntegration = true;
-
};
-
}
+1
modules/nushell/prompt.nu
···
higashi: {start: "0xEC5228", end: "0xEF9651"},
wolumonde: {start: "0x603F26", end: "0x6C4E31"},
chernobog: {start: "0xA94438", end: "0xD24545"},
+
"sd-148036": {start: "0x595CFF", end: "0xC6F8FF"},
}
let user_colors = {
kirara: {start: "0xFF407D", end: "0xEE99C2"},
+23
users/default.nix
···
+
{
+
inputs,
+
lib,
+
tlib,
+
...
+
}:
+
let
+
mkHome =
+
name: system:
+
let
+
pkgs = tlib.makePkgs system;
+
in
+
import "${inputs.home}/modules" {
+
inherit pkgs;
+
configuration = import (./. + "/${name}/default.nix");
+
extraSpecialArgs = {inherit tlib inputs;};
+
};
+
+
users = {
+
"dusk@devel.mobi" = "x86_64-linux";
+
};
+
in
+
lib.mapAttrs mkHome users
+63
users/dusk@devel.mobi/default.nix
···
+
{
+
pkgs,
+
lib,
+
tlib,
+
inputs,
+
...
+
}:
+
let
+
l = lib // builtins;
+
+
signKeyText = builtins.readFile ../../secrets/yusdacra.key.pub;
+
personal = import ../../personal.nix;
+
name = personal.name;
+
email = personal.emails.primary;
+
in
+
{
+
imports =
+
let
+
modulesToEnable = l.flatten [
+
[
+
"zoxide"
+
"fzf"
+
"direnv"
+
"nushell"
+
]
+
# dev stuff
+
[
+
"helix"
+
"git"
+
"ssh"
+
]
+
];
+
in
+
l.flatten [
+
../../modules/persist/null.nix
+
(tlib.prefixStrings "${inputs.self}/users/modules/" modulesToEnable)
+
];
+
+
home = {
+
homeDirectory = "/home/dusk";
+
username = "dusk";
+
stateVersion = "25.11";
+
# file.".ssh/authorized_keys".text = ''
+
# ${signKeyText}
+
# '';
+
};
+
+
programs = {
+
git = {
+
userName = name;
+
userEmail = email;
+
extraConfig = {
+
gpg.format = "ssh";
+
commit.gpgsign = true;
+
user.signingkey = signKeyText;
+
};
+
};
+
};
+
+
services.podman = {
+
enable = true;
+
};
+
}
+1 -6
users/modules/helix/default.nix
···
{
-
inputs,
-
pkgs,
-
...
-
}:
-
{
-
stylix.targets.helix.enable = false;
+
# stylix.targets.helix.enable = false;
programs.helix = {
enable = true;
languages.language = [
+1
users/modules/nushell/aliases.nu
···
+
../../../modules/nushell/aliases.nu
+75
users/modules/nushell/default.nix
···
+
{pkgs, lib, ...}: {
+
programs.carapace.enable = true;
+
programs.carapace.enableNushellIntegration = true;
+
programs.nushell = {
+
enable = true;
+
shellAliases = {
+
myip = lib.mkForce "echo";
+
};
+
extraEnv = ''
+
source-env ${./prompt.nu}
+
'';
+
extraConfig = ''
+
let carapace_completer = {|spans: list<string>|
+
carapace $spans.0 nushell ...$spans
+
| from json
+
| if ($in | default [] | where value == $"($spans | last)ERR" | is-empty) { $in } else { null }
+
}
+
$env.CARAPACE_BRIDGES = 'zsh,fish,bash,inshellisense'
+
+
let fish_completer = {|spans|
+
${lib.getExe pkgs.fish} --command $'complete "--do-complete=($spans | str join " ")"'
+
| $"value(char tab)description(char newline)" + $in
+
| from tsv --flexible --no-infer
+
}
+
+
let zoxide_completer = {|spans|
+
$spans | skip 1 | zoxide query -l ...$in | lines | where {|x| $x != $env.PWD}
+
}
+
+
let multiple_completers = {|spans|
+
## alias fixer start https://www.nushell.sh/cookbook/external_completers.html#alias-completions
+
let expanded_alias = scope aliases
+
| where name == $spans.0
+
| get -i 0.expansion
+
+
let spans = if $expanded_alias != null {
+
$spans
+
| skip 1
+
| prepend ($expanded_alias | split row ' ' | take 1)
+
} else {
+
$spans
+
}
+
## alias fixer end
+
+
match $spans.0 {
+
__zoxide_z | __zoxide_zi => $zoxide_completer
+
_ => $carapace_completer
+
} | do $in $spans
+
}
+
+
$env.config = {
+
show_banner: false,
+
completions: {
+
case_sensitive: false # case-sensitive completions
+
quick: true # set to false to prevent auto-selecting completions
+
partial: true # set to false to prevent partial filling of the prompt
+
algorithm: "fuzzy" # prefix or fuzzy
+
external: {
+
# set to false to prevent nushell looking into $env.PATH to find more suggestions
+
enable: true
+
# set to lower can improve completion performance at the cost of omitting some options
+
max_results: 100
+
completer: $multiple_completers
+
}
+
}
+
}
+
$env.PATH = ($env.PATH |
+
split row (char esep) |
+
append /usr/bin/env
+
)
+
+
source ${./aliases.nu}
+
'';
+
};
+
}
+1
users/modules/nushell/prompt.nu
···
+
../../../modules/nushell/prompt.nu
-2
users/modules/ssh/default.nix
···
-
{ nixosConfig, ... }:
{
programs.ssh = {
enable = true;
compression = true;
hashKnownHosts = true;
addKeysToAgent = "yes";
-
package = nixosConfig.programs.ssh.package;
# Only needed for darcs hub
# extraConfig = ''
# Host hub.darcs.net
+3
users/root/default.nix
···
{ ... }:
{
users.users.root.initialHashedPassword = "$6$XLWo1sPpgp63Zm$XHBbULH9q1gb/.yalPPU/I7EgTcW80bM.moCjIe/qGyOwE47VcXNVbTHloBZdIWQq0MfIG0IxInAu59.oJyos/";
+
home-manager.users.root = {
+
imports = [../modules/nushell];
+
};
}