Compare commits

..

No commits in common. "dbd75eaef065681bfe7d6f31e14fce914ce8852e" and "d55a6dc72c1f26b5763617680187776b12f443c5" have entirely different histories.

9 changed files with 41 additions and 133 deletions

View file

@ -32,16 +32,10 @@ jobs:
experimental-features = pipe-operator experimental-features = pipe-operator
accept-flake-config = true accept-flake-config = true
- uses: cachix/cachix-action@v15
- name: Install and login to attic cache with:
run: | name: daylin
nix profile install "nixpkgs#attic-client" authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
attic login oizys https://attic.dayl.in "${{ secrets.ATTIC_TOKEN }}"
# - uses: cachix/cachix-action@v15
# with:
# name: daylin
# authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
- name: Update nix flake - name: Update nix flake
run: | run: |
@ -57,7 +51,7 @@ jobs:
run: > run: >
nix run . nix run .
-- --
cache build --minimal
--host "othalan" --host "othalan"
--flake . --flake .
--debug --debug

View file

@ -49,14 +49,12 @@
nixConfig = { nixConfig = {
extra-substituters = [ extra-substituters = [
"https://attic.dayl.in/oizys"
"https://hyprland.cachix.org" "https://hyprland.cachix.org"
"https://nixpkgs-wayland.cachix.org" "https://nixpkgs-wayland.cachix.org"
"https://daylin.cachix.org" "https://daylin.cachix.org"
# "https://cache.lix.systems" # "https://cache.lix.systems"
]; ];
extra-trusted-public-keys = [ extra-trusted-public-keys = [
"oizys:DSw3mwVMM/Y+PXSVpkDlU5dLwlORuiJRGPkwr5INSMc="
"hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc=" "hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="
"nixpkgs-wayland.cachix.org-1:3lwxaILxMRkVhehr5StQprHdEo4IrE8sRho9R9HOLYA=" "nixpkgs-wayland.cachix.org-1:3lwxaILxMRkVhehr5StQprHdEo4IrE8sRho9R9HOLYA="
"daylin.cachix.org-1:fLdSnbhKjtOVea6H9KqXeir+PyhO+sDSPhEW66ClE/k=" "daylin.cachix.org-1:fLdSnbhKjtOVea6H9KqXeir+PyhO+sDSPhEW66ClE/k="

View file

@ -27,20 +27,4 @@ To point gitea/forgejo to the shim gitea binary for SSH I symlink the current sy
ln -s /run/current-system/sw/bin/gitea /usr/local/bin/gitea ln -s /run/current-system/sw/bin/gitea /usr/local/bin/gitea
``` ```
## Setting up Attic
Generated a key using command provided in attic docs:
```sh
nix run nixpkgs#openssl -- genrsa -traditional 4096 | base64 -w0
```
And wrote `ATTIC_SERVER_TOKEN_RS256_SECRET_BASE64="output from above"` to `/etc/attic.env`
I generated a token to configure the caches using the following command:
```
atticd-atticadm make-token --sub daylin --push "*" --pull "*" --validity '1y' --create-cache "*" --configure-cache "*" --configure-cache-retention "*" --destroy-cache "*" --delete "*"
```
If I handled secrets via `sops` or `agenix` I think this could be stored directly in the repo.
I also had to modify the firewall so that docker would forward along the requests by caddy to `host.docker.internal` correctly.

View file

@ -1,58 +0,0 @@
{ pkgs, enabled, ... }:
let
atticPort = "5656";
in
{
services.resolved = enabled;
services.fail2ban = enabled // {
maxretry = 5;
bantime = "24h";
};
services.openssh = enabled // {
settings.PasswordAuthentication = false;
};
security.polkit = enabled; # attic was looking for this...
environment.systemPackages = [ pkgs.attic-client ];
# allow docker to forward the request to the host running attic
# https://discourse.nixos.org/t/docker-container-not-resolving-to-host/30259/6
networking.firewall.extraCommands = "iptables -A INPUT -p tcp --destination-port ${atticPort} -s 172.16.0.0/12 -j ACCEPT";
services.atticd = enabled // {
# Replace with absolute path to your credentials file
environmentFile = "/etc/atticd.env";
settings = {
listen = "[::]:${atticPort}";
jwt = { };
# Data chunking
#
# Warning: If you change any of the values here, it will be
# difficult to reuse existing chunks for newly-uploaded NARs
# since the cutpoints will be different. As a result, the
# deduplication ratio will suffer for a while after the change.
chunking = {
# The minimum NAR size to trigger chunking
#
# If 0, chunking is disabled entirely for newly-uploaded NARs.
# If 1, all NARs are chunked.
nar-size-threshold = 64 * 1024; # 64 KiB
# The preferred minimum size of a chunk, in bytes
min-size = 16 * 1024; # 16 KiB
# The preferred average size of a chunk, in bytes
avg-size = 64 * 1024; # 64 KiB
# The preferred maximum size of a chunk, in bytes
max-size = 256 * 1024; # 256 KiB
};
};
};
}

View file

@ -2,6 +2,12 @@
{ {
security.sudo.wheelNeedsPassword = false; security.sudo.wheelNeedsPassword = false;
services.resolved = enabled;
services.fail2ban = enabled // {
maxretry = 5;
bantime = "24h";
};
# # added to make using `pip install` work in docker build # # added to make using `pip install` work in docker build
# networking.nameservers = [ "8.8.8.8"]; # networking.nameservers = [ "8.8.8.8"];
@ -14,6 +20,12 @@
]; ];
}; };
services.openssh = enabled // {
settings.PasswordAuthentication = false;
};
# users.mutableUsers = false;
# Use the GRUB 2 boot loader. # Use the GRUB 2 boot loader.
boot.loader.grub = enabled // { boot.loader.grub = enabled // {
device = "/dev/sda"; # or "nodev" for efi only device = "/dev/sda"; # or "nodev" for efi only

View file

@ -10,6 +10,5 @@
graphviz graphviz
typst typst
charm-freeze charm-freeze
attic-client
]); ]);
} }

View file

@ -1,5 +1,5 @@
## nix begat oizys ## nix begat oizys
import std/[os, osproc, tables, sequtils, strformat, strutils] import std/[os, tables, sequtils, strformat, strutils]
import hwylterm, hwylterm/[cligen, logging] import hwylterm, hwylterm/[cligen, logging]
import oizys/[context, github, nix, overlay, logging] import oizys/[context, github, nix, overlay, logging]
@ -53,9 +53,9 @@ overlay:
## nix build ## nix build
nixBuild(minimal, rest) nixBuild(minimal, rest)
proc cache(name: string = "oizys", service: string = "attic", jobs: int = countProcessors()) = proc cache(minimal: bool = false, name: string = "daylin") =
## build and push store paths ## build and push to cachix
nixBuildWithCache(name, rest, service, jobs) nixBuildWithCache(minimal, name, rest)
proc osCmd() = proc osCmd() =
## nixos-rebuild ## nixos-rebuild
@ -97,8 +97,7 @@ when isMainModule:
"ref" : "git ref/branch/tag to trigger workflow on" "ref" : "git ref/branch/tag to trigger workflow on"
} }
cacheHelp = //{ cacheHelp = //{
"name" : "name of cachix binary cache", "name" : "name of cachix binary cache"
"jobs" : "jobs when pushing paths"
} // sharedHelp } // sharedHelp
let let
osUsage = $bb("$command [[subcmd] $args\n$doc[bold]Options[/]:\n$options") osUsage = $bb("$command [[subcmd] $args\n$doc[bold]Options[/]:\n$options")

View file

@ -9,7 +9,7 @@ import hwylterm
func addArgs*(cmd: var string, args: openArray[string]) = func addArgs*(cmd: var string, args: openArray[string]) =
cmd &= " " & args.join(" ") cmd &= " " & args.join(" ")
func addArg*(cmd: var string, arg: string ) = func addArg*(cmd: var string, arg: string) =
cmd &= " " & arg cmd &= " " & arg
proc runCmd*(cmd: string): int = proc runCmd*(cmd: string): int =

View file

@ -193,7 +193,6 @@ proc writeDervationsToStepSummary(drvs: seq[string]) =
let output = open(summaryFilePath,fmAppend) let output = open(summaryFilePath,fmAppend)
output.writeLine("| derivation | hash |\n|---|---|") output.writeLine("| derivation | hash |\n|---|---|")
output.writeLine(rows.join("\n")) output.writeLine(rows.join("\n"))
close output
proc nixBuild*(minimal: bool, rest: seq[string]) = proc nixBuild*(minimal: bool, rest: seq[string]) =
var cmd = nixCommand("build") var cmd = nixCommand("build")
@ -234,42 +233,23 @@ proc nixBuildHostDry*(minimal: bool, rest: seq[string]) =
let output = parseDryRunOutput err let output = parseDryRunOutput err
display output display output
proc nixBuildWithCache*(minimal: bool, name: string, rest:seq[string]) =
proc nixBuildWithCache*(name: string, rest:seq[string], service: string, jobs: int) = if findExe("cachix") == "": fatalQuit "is cachix installed?"
## build individual derivations not cached and push to cache
if findExe(service) == "": fatalQuit fmt"is {service} installed?"
info bbfmt"building and pushing to cache: [b]{name}" info bbfmt"building and pushing to cache: [b]{name}"
debug "determining missing cache hits" var cmd = "cachix"
let drvs = systemPathDrvsToBuild() cmd.addArgs ["watch-exec","--"]
if drvs.len == 0: cmd.addArg "nix build"
info "nothing to build" if minimal:
quit "exiting...", QuitSuccess debug "populating args with derivations not built/cached"
let drvs = systemPathDrvsToBuild()
for drv in drvs: if drvs.len == 0:
var cmd = "nix build" info "nothing to build"
cmd.addArg drv quit "exiting...", QuitSuccess
cmd.addArgs rest cmd.addArgs drvs
let buildErr = runCmd(cmd) cmd.addArg "--no-link"
if buildErr != 0: else:
error "failed to build: " & drv cmd.addArgs nixosConfigAttrs()
continue cmd.addArgs rest
let err = runCmd(cmd)
let results = collect( quit err
for k, p in walkDir(".", relative = true):
if k in { pcLinkToDir, pcLinkToFile} and p.startsWith("result"):
p
)
cmd = service
cmd.addArg "push"
cmd.addArg name
cmd.addArg "--jobs"
cmd.addArg $jobs
cmd.addArgs results
let pushErr = runCmd(cmd)
if pushErr != 0:
errorQuit "failed to push build to cache"
for p in results:
removeFile p