Compare commits

..

8 commits

Author SHA1 Message Date
Sean Buckley
0be59680b4 fix terminal titles 2024-06-22 13:12:18 -04:00
Sean Buckley
a50b4b1f79 allow docker permissions 2024-06-18 19:02:11 -04:00
Sean Buckley
79f1a07fc5 deploy: print hostnames while processing 2024-06-17 01:19:30 -04:00
Sean Buckley
c50222cfe7 deploy: allow excluding hosts 2024-06-17 01:01:16 -04:00
Sean Buckley
0fbf2573cc add swapspace module 2024-06-16 23:54:51 -04:00
Sean Buckley
aa7c7749ed cli: simplify and rename "nr" to "nixpkgs" 2024-06-16 23:44:31 -04:00
Sean Buckley
6c8bfaf6e9 go back to old nixpkgs pin 2024-06-16 21:23:59 -04:00
Sean Buckley
e43e174fd4 flake.lock: Update
Flake lock file updates:

• Updated input 'impermanence':
    'github:nix-community/impermanence/a33ef102a02ce77d3e39c25197664b7a636f9c30' (2024-02-26)
  → 'github:nix-community/impermanence/27979f1c3a0d3b9617a3563e2839114ba7d48d3f' (2024-06-09)
• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/ad57eef4ef0659193044870c731987a6df5cf56b' (2024-05-29)
  → 'github:NixOS/nixpkgs/57d6973abba7ea108bac64ae7629e7431e0199b6' (2024-06-12)
2024-06-13 01:51:34 -04:00
8 changed files with 63 additions and 25 deletions

View file

@ -2,11 +2,11 @@
"nodes": {
"impermanence": {
"locked": {
"lastModified": 1708968331,
"narHash": "sha256-VUXLaPusCBvwM3zhGbRIJVeYluh2uWuqtj4WirQ1L9Y=",
"lastModified": 1717932370,
"narHash": "sha256-7C5lCpiWiyPoIACOcu2mukn/1JRtz6HC/1aEMhUdcw0=",
"owner": "nix-community",
"repo": "impermanence",
"rev": "a33ef102a02ce77d3e39c25197664b7a636f9c30",
"rev": "27979f1c3a0d3b9617a3563e2839114ba7d48d3f",
"type": "github"
},
"original": {
@ -17,11 +17,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1716948383,
"narHash": "sha256-SzDKxseEcHR5KzPXLwsemyTR/kaM9whxeiJohbL04rs=",
"lastModified": 1718160348,
"narHash": "sha256-9YrUjdztqi4Gz8n3mBuqvCkMo4ojrA6nASwyIKWMpus=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "ad57eef4ef0659193044870c731987a6df5cf56b",
"rev": "57d6973abba7ea108bac64ae7629e7431e0199b6",
"type": "github"
},
"original": {

View file

@ -14,6 +14,20 @@
forAllSystems = lib.genAttrs [ "x86_64-linux" ];
pins = {
nix.registry.nixpkgs.to = {
inherit (nixpkgs) rev;
owner = "NixOS";
repo = "nixpkgs";
type = "github";
};
nix.registry.bck.to = {
owner = "buckley310";
repo = "nixos-config";
type = "github";
};
};
in
{
formatter = forAllSystems (system:
@ -33,13 +47,9 @@
nixosModules =
{
inherit pins;
inherit (impermanence.nixosModules) impermanence;
pkgs.nixpkgs.overlays = [ (_: mypkgs) ];
pins.nix.registry.bck.to = {
owner = "buckley310";
repo = "nixos-config";
type = "github";
};
} //
self.lib.dirToAttrs ./modules import;

View file

@ -43,8 +43,6 @@
(writeShellScriptBin "dirt" "while sleep 1; do grep '^Dirty:' /proc/meminfo ; done")
(writeShellScriptBin "nr" "exec nix repl \"$(nix eval nixpkgs#path)\"")
(lib.hiPrio (writeShellScriptBin "iftop" ''
exec ${iftop}/bin/iftop -P -m100M "$@"
''))
@ -127,6 +125,7 @@
set -g history-limit 10000
set -g pane-base-index 1
set -g renumber-windows on
set -g set-titles on
set -sa terminal-overrides ",*256color:Tc"
# escape-time reduces the time where the escape key acts as an alt key
set -s escape-time 1
@ -163,5 +162,6 @@
alias day='date "+%Y-%m-%d"'
alias grep='grep --color=auto'
alias tmp='cd "$(mktemp -d)"'
alias nixpkgs='nix repl --file flake:nixpkgs'
'';
}

View file

@ -30,6 +30,8 @@ let
"-jobs $(jobs -pr | wc -l)"
];
termtitle = ''\[\e]0;\u@\h: \w\a\]'';
in
{
environment.systemPackages = [
@ -48,7 +50,7 @@ in
local remote=y
[ "$XDG_SESSION_TYPE" = "x11" ] && unset remote
[ "$XDG_SESSION_TYPE" = "wayland" ] && unset remote
PS1="$(powerline-go ${toString args})"
PS1="${termtitle}$(powerline-go ${toString args})"
}
[ "$TERM" = "linux" ] || PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
'';

View file

@ -18,9 +18,6 @@ with lib;
systemd.services.docker.path = [
pkgs.openssh
];
programs.bash.interactiveShellInit = ''
((UID)) && alias docker="sudo --preserve-env=SSH_AUTH_SOCK docker"
'';
virtualisation.docker = {
enable = true;
enableOnBoot = false;

View file

@ -11,6 +11,7 @@
extraGroups = [
"audio"
"dialout"
"docker"
"input"
"networkmanager"
"video"

20
modules/swapspace.nix Normal file
View file

@ -0,0 +1,20 @@
{ config, lib, pkgs, ... }:
let
cfg = config.sconfig.swapspace;
in
{
options.sconfig.swapspace = {
enable = lib.mkEnableOption "swapspace";
swapPath = lib.mkOption { type = lib.types.path; };
};
config = lib.mkIf cfg.enable {
systemd.tmpfiles.rules = [ "d ${cfg.swapPath} 0700 root root" ];
systemd.services.swapspace = {
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Restart = "always";
ExecStart = "${pkgs.swapspace}/bin/swapspace --swappath='${cfg.swapPath}'";
};
};
};
}

View file

@ -27,16 +27,24 @@ def get_deployment():
def expand(ln):
hosts = set()
for item in ln.split(","):
if item == "all":
hosts.update(depl)
elif item in tags:
hosts.update(name for name in depl if item in depl[name]["tags"])
if item[0] == "-":
item = item[1:]
action = hosts.difference_update
else:
hosts.add(item)
action = hosts.update
if item == "all":
action(depl)
elif item in tags:
action(name for name in depl if item in depl[name]["tags"])
else:
action([item])
for host in hosts:
for c in host:
if not c in (ascii_letters + digits + "-"):
raise RuntimeError(f"Invalid hostname: {host}")
return sorted(hosts)
@ -84,6 +92,8 @@ def check(hosts):
print("#" * 64)
for host in hosts:
print(host.rjust(hostwidth + 1), end=" ", flush=True)
current_sys, cur_kernel, boot_kernel = (
run(
[
@ -105,8 +115,6 @@ def check(hosts):
reboot_needed = cur_kernel != boot_kernel
update_needed = current_sys != new_sys[host]
print(host.rjust(hostwidth + 1), end=" ")
if not (reboot_needed or update_needed):
print(icon_good, "[OK]")
continue
@ -142,9 +150,9 @@ def push(hosts):
def rexec(hosts, cmd):
hostwidth = max(map(len, hosts))
for host in hosts:
print(host.rjust(hostwidth), end=" ", flush=True)
r = run(["ssh", host, "--"] + cmd, stdout=PIPE, stderr=STDOUT)
lines = r.stdout.decode("utf8").strip("\n").splitlines()
print(host.rjust(hostwidth), end=" ")
print(icon_bad if r.returncode else icon_good, end=" ")
if len(lines) == 1:
print(lines[0])