chore: fix formatting and add treefmt

This commit is contained in:
Tim Schubert 2025-07-26 20:56:40 +02:00
parent a26418c9c3
commit 5d55e620da
No known key found for this signature in database
10 changed files with 49 additions and 36 deletions

2
.envrc
View file

@ -1,3 +1,5 @@
#!/bin/sh
watch_file devshell.nix watch_file devshell.nix
use flake use flake

View file

@ -4,4 +4,4 @@ updates:
directory: "/" directory: "/"
schedule: schedule:
interval: "weekly" interval: "weekly"
assignees: [ "dadada" ] assignees: ["dadada"]

View file

@ -1,26 +1,24 @@
name: Continuous Integration name: Continuous Integration
on: on:
pull_request: pull_request:
push: push:
branches: [main] branches: [main]
jobs: jobs:
checks: checks:
name: "Checks" name: "Checks"
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: cachix/install-nix-action@v26 - uses: cachix/install-nix-action@v26
with: with:
nix_path: nixpkgs=channel:nixos-stable nix_path: nixpkgs=channel:nixos-stable
extra_nix_config: | extra_nix_config: |
experimental-features = nix-command flakes experimental-features = nix-command flakes
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
system-features = nixos-test benchmark big-parallel kvm system-features = nixos-test benchmark big-parallel kvm
- uses: cachix/cachix-action@v14 - uses: cachix/cachix-action@v14
with: with:
name: dadada name: dadada
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}' signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: nix flake check - run: nix flake check

View file

@ -3,7 +3,6 @@ on:
workflow_dispatch: # allows manual triggering workflow_dispatch: # allows manual triggering
schedule: schedule:
- cron: '0 0 * * 0' # runs weekly on Sunday at 00:00 - cron: '0 0 * * 0' # runs weekly on Sunday at 00:00
jobs: jobs:
lockfile: lockfile:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -16,6 +15,6 @@ jobs:
uses: DeterminateSystems/update-flake-lock@v21 uses: DeterminateSystems/update-flake-lock@v21
with: with:
pr-title: "Update flake.lock" # Title of PR to be created pr-title: "Update flake.lock" # Title of PR to be created
pr-labels: | # Labels to be set on the PR pr-labels: | # Labels to be set on the PR
dependencies dependencies
automated automated

View file

@ -24,7 +24,7 @@
name = "format"; name = "format";
help = "Format the project"; help = "Format the project";
command = '' command = ''
nixpkgs-fmt . treefmt .
''; '';
category = "dev"; category = "dev";
} }

View file

@ -21,15 +21,14 @@ let
nixpkgs.lib.nixosSystem { nixpkgs.lib.nixosSystem {
inherit system; inherit system;
modules = modules = [
[ {
{ nixpkgs.overlays = nixpkgs.lib.attrValues self.overlays;
nixpkgs.overlays = nixpkgs.lib.attrValues self.overlays; }
} ]
] ++ (nixpkgs.lib.attrValues self.nixosModules)
++ (nixpkgs.lib.attrValues self.nixosModules) ++ [ agenix.nixosModules.age ]
++ [ agenix.nixosModules.age ] ++ extraModules;
++ extraModules;
}; };
in in
{ {

View file

@ -1,4 +1,9 @@
{ config, lib, pkgs, ... }: {
config,
lib,
pkgs,
...
}:
{ {
imports = [ imports = [
@ -124,7 +129,7 @@
configs = { configs = {
home = { home = {
SUBVOLUME = "/home/dadada"; SUBVOLUME = "/home/dadada";
ALLOW_USERS= ["dadada"]; ALLOW_USERS = [ "dadada" ];
TIMELINE_CREATE = true; TIMELINE_CREATE = true;
TIMELINE_CLEANUP = true; TIMELINE_CLEANUP = true;
TIMELINE_MIN_AGE = "1800"; TIMELINE_MIN_AGE = "1800";
@ -213,7 +218,7 @@
# owner = "paperless"; # owner = "paperless";
# }; # };
# }; # };
# Create compressing swap space in RAM # Create compressing swap space in RAM
zramSwap.enable = true; zramSwap.enable = true;
} }

View file

@ -5,12 +5,14 @@
nixpkgs, nixpkgs,
agenix, agenix,
devshell, devshell,
treefmt-nix,
... ...
}@inputs: }@inputs:
(flake-utils.lib.eachDefaultSystem ( (flake-utils.lib.eachDefaultSystem (
system: system:
let let
pkgs = import nixpkgs { inherit system; }; pkgs = import nixpkgs { inherit system; };
treefmtEval = treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
in in
{ {
devShells.default = devShells.default =
@ -26,7 +28,7 @@
in in
import ./devshell.nix { inherit pkgs extraModules; }; import ./devshell.nix { inherit pkgs extraModules; };
formatter = pkgs.nixfmt-tree; formatter = treefmtEval.config.build.wrapper;
packages = import ./pkgs { inherit pkgs; } // { packages = import ./pkgs { inherit pkgs; } // {
installer-iso = self.nixosConfigurations.installer.config.system.build.isoImage; installer-iso = self.nixosConfigurations.installer.config.system.build.isoImage;
@ -34,7 +36,6 @@
} }
)) ))
// { // {
hmModules = import ./home/modules.nix { lib = nixpkgs.lib; }; hmModules = import ./home/modules.nix { lib = nixpkgs.lib; };
nixosConfigurations = import ./nixos/configurations.nix inputs; nixosConfigurations = import ./nixos/configurations.nix inputs;

View file

@ -1,3 +1,4 @@
{ pkgs }: { { pkgs }:
citizen-cups = pkgs.callPackage ./citizen-cups.nix {}; {
citizen-cups = pkgs.callPackage ./citizen-cups.nix { };
} }

8
treefmt.nix Normal file
View file

@ -0,0 +1,8 @@
{ pkgs, ... }:
{
projectRootFile = "flake.nix";
programs.nixfmt.enable = true;
programs.shellcheck.enable = pkgs.hostPlatform.system != "riscv64-linux";
programs.shfmt.enable = pkgs.hostPlatform.system != "riscv64-linux";
programs.yamlfmt.enable = true;
}