flake: migrate formatter to treefmt-nix #885

Merged
JakeHillion merged 1 commits from jj/xuyvlqrtsmpy into main 2026-02-06 00:08:14 +00:00
3 changed files with 68 additions and 19 deletions

No files matched your search

Generated
+22 -1
View File
@@ -520,7 +520,8 @@
"nixpkgs-unstable": "nixpkgs-unstable", "nixpkgs-unstable": "nixpkgs-unstable",
"ogygia": "ogygia", "ogygia": "ogygia",
"qnaplcd-menu": "qnaplcd-menu", "qnaplcd-menu": "qnaplcd-menu",
"status-jakehillion-me": "status-jakehillion-me" "status-jakehillion-me": "status-jakehillion-me",
"treefmt-nix": "treefmt-nix_3"
} }
}, },
"rust-analyzer-src": { "rust-analyzer-src": {
@@ -712,6 +713,26 @@
"repo": "treefmt-nix", "repo": "treefmt-nix",
"type": "github" "type": "github"
} }
},
"treefmt-nix_3": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1770228511,
"narHash": "sha256-wQ6NJSuFqAEmIg2VMnLdCnUc0b7vslUohqqGGD+Fyxk=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "337a4fe074be1042a35086f15481d763b8ddc0e7",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",
+30 -14
View File
@@ -7,6 +7,9 @@
flake-utils.url = "github:numtide/flake-utils"; flake-utils.url = "github:numtide/flake-utils";
treefmt-nix.url = "github:numtide/treefmt-nix";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
darwin.url = "github:lnl7/nix-darwin"; darwin.url = "github:lnl7/nix-darwin";
darwin.inputs.nixpkgs.follows = "nixpkgs"; darwin.inputs.nixpkgs.follows = "nixpkgs";
@@ -60,6 +63,7 @@
, ogygia , ogygia
, qnaplcd-menu , qnaplcd-menu
, status-jakehillion-me , status-jakehillion-me
, treefmt-nix
, ... , ...
}@inputs: }@inputs:
let let
@@ -80,6 +84,12 @@
}) })
]; ];
mkSystem = import ./lib/mkSystem.nix { inherit inputs; }; mkSystem = import ./lib/mkSystem.nix { inherit inputs; };
treefmtEval = pkgs: treefmt-nix.lib.evalModule pkgs {
projectRootFile = "flake.nix";
programs.nixpkgs-fmt.enable = true;
programs.gofumpt.enable = true;
programs.black.enable = true;
};
in in
{ {
inherit mkSystem; inherit mkSystem;
@@ -128,7 +138,25 @@
}; };
}; };
} // flake-utils.lib.eachSystem [ "x86_64-linux" ] ( } // nixpkgs.lib.recursiveUpdate
(flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = getSystemOverlays system { };
config = { allowUnfree = true; };
};
in
{
formatter = (treefmtEval pkgs).config.build.wrapper;
checks = {
formatting = (treefmtEval pkgs).config.build.check self;
};
packages.caddy-with-dns = pkgs.caddy-with-dns;
}))
(flake-utils.lib.eachSystem [ "x86_64-linux" ] (
system: system:
let let
pkgs = import nixpkgs { pkgs = import nixpkgs {
@@ -153,17 +181,5 @@
}}/bin/generate-snapshots"; }}/bin/generate-snapshots";
}; };
} }
) // flake-utils.lib.eachDefaultSystem (system: ));
let
pkgs = import nixpkgs {
inherit system;
overlays = getSystemOverlays system { };
config = { allowUnfree = true; };
};
in
{
formatter = nixpkgs.legacyPackages.${system}.nixpkgs-fmt;
packages.caddy-with-dns = pkgs.caddy-with-dns;
});
} }
+16 -4
View File
@@ -8,20 +8,32 @@ from nltk.corpus import wordnet as wn
try: try:
wn.ensure_loaded() wn.ensure_loaded()
except LookupError: except LookupError:
nltk.download('wordnet') nltk.download("wordnet")
def get_adjectives_and_nouns(): def get_adjectives_and_nouns():
adjectives = [word for word in wn.all_lemma_names(pos='a') if len(word) > 1 and '_' not in word and '-' not in word] adjectives = [
nouns = [word for word in wn.all_lemma_names(pos='n') if len(word) > 1 and '_' not in word and '-' not in word] word
for word in wn.all_lemma_names(pos="a")
if len(word) > 1 and "_" not in word and "-" not in word
]
nouns = [
word
for word in wn.all_lemma_names(pos="n")
if len(word) > 1 and "_" not in word and "-" not in word
]
return adjectives, nouns return adjectives, nouns
adjectives, nouns = get_adjectives_and_nouns() adjectives, nouns = get_adjectives_and_nouns()
def generate_random_word_list(N): def generate_random_word_list(N):
selected_adjectives = random.sample(adjectives, N) selected_adjectives = random.sample(adjectives, N)
noun = random.choice(nouns) noun = random.choice(nouns)
return selected_adjectives + [noun] return selected_adjectives + [noun]
while True: while True:
random_word_list = generate_random_word_list(2) random_word_list = generate_random_word_list(2)
input(' '.join(random_word_list)) input(" ".join(random_word_list))