Skip to content

Commit 043339a

Browse files
committed
flake: rewrite, use flake-parts, split flake into flake/
1 parent 1c39a5d commit 043339a

5 files changed

Lines changed: 147 additions & 132 deletions

File tree

flake.lock

Lines changed: 61 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 21 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -2,135 +2,30 @@
22
description = "A Flake-native deployment tool for distributed NixOS and Darwin clusters.";
33

44
inputs = {
5-
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
6-
};
7-
8-
outputs = {
9-
self,
10-
nixpkgs,
11-
}: let
12-
allSystems = [
13-
"aarch64-darwin"
14-
"aarch64-linux"
15-
"x86_64-darwin"
16-
"x86_64-linux"
17-
];
18-
19-
forAllSystems = f:
20-
nixpkgs.lib.genAttrs allSystems (system:
21-
f {
22-
pkgs = import self.inputs.nixpkgs {
23-
inherit system;
24-
};
25-
});
26-
in {
27-
formatter = self.inputs.nixpkgs.lib.genAttrs allSystems (system: self.packages.${system}.formatter);
28-
29-
packages = forAllSystems ({pkgs}: rec {
30-
formatter = pkgs.writeShellApplication {
31-
name = "formatter";
32-
33-
runtimeInputs = with pkgs; [
34-
alejandra
35-
diffutils
36-
findutils
37-
go
38-
gopls
39-
nodePackages.prettier
40-
shfmt
41-
];
42-
43-
text = builtins.readFile ./utils/formatter.sh;
44-
};
45-
46-
nynx = pkgs.buildGoModule {
47-
pname = "nynx";
48-
src = ./src;
49-
vendorHash = null;
50-
51-
nativeBuildInputs = with pkgs; [
52-
makeWrapper
53-
];
54-
55-
postInstall = ''
56-
wrapProgram $out/bin/nynx \
57-
--prefix PATH : ${pkgs.lib.makeBinPath [pkgs.nix-eval-jobs]}
58-
'';
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
596

60-
version =
61-
if self ? shortRev
62-
then "git-${self.shortRev}"
63-
else "dev";
64-
};
65-
66-
default = nynx;
67-
});
68-
69-
# darwinConfigurations = {
70-
# darwintest = self.inputs.nix-darwin.lib.darwinSystem {
71-
# system = "aarch64-darwin";
72-
# modules = [
73-
# {
74-
# networking.hostName = "darwintest";
75-
# }
76-
# ];
77-
# };
78-
# };
79-
80-
devShells = forAllSystems ({pkgs}: {
81-
default = pkgs.mkShell {
82-
packages = with pkgs;
83-
[
84-
go
85-
gopls
86-
nixd
87-
nodePackages.prettier
88-
shfmt
89-
]
90-
++ [
91-
self.packages.${pkgs.system}.formatter
92-
self.packages.${pkgs.system}.nynx
93-
];
94-
};
95-
});
96-
97-
nixosConfigurations = {
98-
nixostest = self.inputs.nixpkgs.lib.nixosSystem {
99-
system = "x86_64-linux";
100-
modules = [
101-
({...}: {
102-
imports = [];
103-
104-
boot.loader.systemd-boot.enable = true;
105-
boot.loader.efi.canTouchEfiVariables = true;
106-
107-
fileSystems."/" = {
108-
device = "/dev/sda1";
109-
fsType = "ext4";
110-
};
111-
112-
networking.hostName = "nixostest";
113-
services.openssh.enable = true;
114-
users.users.root.initialPassword = "changeme";
115-
system.stateVersion = "25.05";
116-
})
117-
];
118-
};
7+
treefmt-nix = {
8+
url = "github:numtide/treefmt-nix";
9+
inputs.nixpkgs.follows = "nixpkgs";
11910
};
12011

121-
nynxDeployments = {
122-
nixostest = {
123-
hostname = "nixostest"; # Will be assumed from deployment name if not specified.
124-
output = self.nixosConfigurations.nixostest.config.system.build.toplevel;
125-
# type = "nixos"; # Will be inferred based on the output.
126-
user = "root";
127-
};
12+
flake-parts.url = "github:hercules-ci/flake-parts";
13+
};
12814

129-
# fortree = {
130-
# output = self.inputs.nixcfg.darwinConfigurations.fortree.config.system.build.toplevel;
131-
# user = "aly";
132-
# type = "darwin";
133-
# };
15+
outputs = inputs @ {flake-parts, ...}:
16+
flake-parts.lib.mkFlake {inherit inputs;} {
17+
systems = [
18+
"aarch64-darwin"
19+
"aarch64-linux"
20+
"x86_64-darwin"
21+
"x86_64-linux"
22+
];
23+
24+
imports = [
25+
./flake/devShells.nix
26+
./flake/packages.nix
27+
./flake/treefmt.nix
28+
inputs.treefmt-nix.flakeModule
29+
];
13430
};
135-
};
13631
}

flake/devShells.nix

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
_: {
2+
perSystem = {
3+
config,
4+
lib,
5+
pkgs,
6+
self',
7+
...
8+
}: {
9+
devShells.default = pkgs.mkShell {
10+
packages = with pkgs;
11+
[
12+
go
13+
gopls
14+
nixd
15+
nodePackages.prettier
16+
]
17+
++ lib.attrValues config.treefmt.build.programs
18+
++ [
19+
self'.packages.nynx
20+
];
21+
};
22+
};
23+
}

flake/packages.nix

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
_: {
2+
perSystem = {
3+
pkgs,
4+
self',
5+
...
6+
}: {
7+
packages = rec {
8+
nynx = pkgs.buildGoModule {
9+
pname = "nynx";
10+
src = ../src;
11+
vendorHash = null;
12+
13+
nativeBuildInputs = with pkgs; [
14+
makeWrapper
15+
];
16+
17+
postInstall = ''
18+
wrapProgram $out/bin/nynx \
19+
--prefix PATH : ${pkgs.lib.makeBinPath [pkgs.nix-eval-jobs]}
20+
'';
21+
22+
version =
23+
if self' ? shortRev
24+
then "git-${self'.shortRev}"
25+
else "dev";
26+
};
27+
28+
default = nynx;
29+
};
30+
};
31+
}

flake/treefmt.nix

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
_: {
2+
perSystem = _: {
3+
treefmt.config.programs = {
4+
alejandra.enable = true;
5+
deadnix.enable = true;
6+
gofmt.enable = true;
7+
prettier.enable = true;
8+
statix.enable = true;
9+
};
10+
};
11+
}

0 commit comments

Comments
 (0)