Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[READY] nix.treewide: remove flake-parts #800

Merged
merged 15 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 7 additions & 25 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 24 additions & 31 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,31 @@
nixConfig.bash-prompt = "\\[\\033[01;32m\\][nix-flakes \\W] \$\\[\\033[00m\\] ";

inputs = {
flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
microvm = {
url = "github:sarcasticadmin/microvm.nix/rh/1707108673virtio";
inputs.nixpkgs.follows = "nixpkgs";
inputs.spectrum.follows = "";
}; # Currently using this fork since the upstream seems to be causing an issue
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
disko.inputs.nixpkgs.follows = "nixpkgs-unstable";
disko.url = "github:nix-community/disko/e55f9a8678adc02024a4877c2a403e3f6daf24fe";
microvm.inputs.nixpkgs.follows = "nixpkgs-2405";
microvm.inputs.spectrum.follows = "";
# Currently using this fork since the upstream seems to be causing an issue
microvm.url = "github:sarcasticadmin/microvm.nix/rh/1707108673virtio";
# nixpkgs-2405 has been pinned to this rev to maintain parity from before flake-parts was removed
# If you want to bump this input, change it back to `github:NixOS/nixpkgs/nixos-24.05` and lock the flake again
nixpkgs-2405.url = "github:NixOS/nixpkgs?rev=d51c28603def282a24fa034bcb007e2bcb5b5dd0";
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs-unstable";
};
disko = {
url = "github:nix-community/disko/e55f9a8678adc02024a4877c2a403e3f6daf24fe";
inputs.nixpkgs.follows = "nixpkgs-unstable";
};
nixpkgs.follows = "nixpkgs-2405";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs-unstable";
treefmt-nix.url = "github:numtide/treefmt-nix";
};

outputs =
inputs:
(inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = [
"x86_64-linux"
"aarch64-linux"
];
imports = [ ./nix/flake-module.nix ];
})
// {
formatter = import ./nix/formatter inputs;
formatterModule = import ./nix/formatterModule inputs;
};
outputs = inputs: {
checks = import ./nix/checks inputs;
devShells = import ./nix/dev-shells inputs;
formatter = import ./nix/formatter inputs;
formatterModule = import ./nix/formatterModule inputs;
legacyPackages = import ./nix/legacy-packages inputs;
library = import ./nix/library inputs;
nixosConfigurations = import ./nix/nixos-configurations inputs;
nixosModules = import ./nix/nixos-modules inputs;
overlays = import ./nix/overlays inputs;
packages = import ./nix/packages inputs;
};
}
10 changes: 5 additions & 5 deletions nix/tests/core.nix → nix/checks/core.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ inputs, pkgs, ... }:
{ inputs }:
let
chomp = "103";
prefix = "2001:470:f026:${chomp}";
Expand Down Expand Up @@ -75,11 +75,11 @@ in
inherit inputs;
};
imports = [
../machines/core/master.nix
../modules/facts.nix
../nixos-configurations/core-master/configuration.nix
../nixos-modules/facts.nix
];

facts = lib.mkForce {
scale-network.facts = lib.mkForce {
ipv4 = "${coremasterAddr.ipv4}/24";
ipv6 = "${coremasterAddr.ipv6}/64";
eth = "eth1";
Expand All @@ -89,7 +89,7 @@ in
systemd.services.systemd-networkd.environment.SYSTEMD_LOG_LEVEL = "debug";
systemd.network = {
networks = {
# Override the phyiscal interface config
# Override the physical interface config
"10-lan" = lib.mkForce {
name = "eth1";
enable = true;
Expand Down
93 changes: 93 additions & 0 deletions nix/checks/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
inputs:
let
inherit (inputs.nixpkgs)
lib
;

inherit (lib.attrsets)
genAttrs
;

inherit (lib.sources)
cleanSource
;
in
genAttrs
[
"x86_64-linux"
"aarch64-linux"
]
(
system:
let
pkgs = inputs.self.legacyPackages.${system};
in
{
core = pkgs.testers.runNixOSTest (import ./core.nix { inherit inputs; });
loghost = pkgs.testers.runNixOSTest ./loghost.nix;

pytest-facts =
let
testPython = (
pkgs.python3.withPackages (
pythonPackages: with pythonPackages; [
pylint
pytest
jinja2
]
)
);
in
(pkgs.runCommand "pytest-facts" { } ''
cp -r --no-preserve=mode ${cleanSource inputs.self}/* .
cd facts
${testPython}/bin/pylint --persistent n *.py
${testPython}/bin/pytest -vv -p no:cacheprovider
touch $out
'');

duplicates-facts = (
pkgs.runCommand "duplicates-facts" { buildInputs = [ pkgs.fish ]; } ''
cp -r --no-preserve=mode ${cleanSource inputs.self}/* .
cd facts
fish test_duplicates.fish
touch $out
''
);

perl-switches = (
pkgs.runCommand "perl-switches"
{
buildInputs = [
pkgs.gnumake
pkgs.perl
];
}
''
cp -r --no-preserve=mode ${cleanSource inputs.self}/* .
cd switch-configuration
make .lint
make .build-switch-configs
touch $out
''
);

openwrt-golden =
pkgs.runCommand "openwrt-golden"
{
buildInputs = [
pkgs.diffutils
pkgs.gomplate
];
}
''
cp -r --no-preserve=mode ${cleanSource inputs.self}/* .
cd tests/unit/openwrt
mkdir -p $out/tmp/ar71xx
${pkgs.bash}/bin/bash test.sh -t ar71xx -o $out
'';

formatting = inputs.self.formatterModule.${system}.config.build.check inputs.self;

}
)
4 changes: 3 additions & 1 deletion nix/tests/loghost.nix → nix/checks/loghost.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
name = "loghost";

nodes.machine1 = {
imports = [ ../machines/loghost.nix ];
imports = [
../nixos-configurations/loghost/base.nix
];
virtualisation.graphics = false;
};

Expand Down
75 changes: 75 additions & 0 deletions nix/dev-shells/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
inputs:
inputs.nixpkgs.lib.genAttrs
[
"x86_64-linux"
"aarch64-linux"
]
(
system:
let
pkgs = inputs.self.legacyPackages.${system};

scalePython = [
(pkgs.python3.withPackages (
ps: with ps; [
pytest
pylint
ipdb
]
))
];

global = with pkgs; [
bash
curl
fish
git
jq
kermit
screen
glibcLocales
];

openwrtSub = with pkgs; [
expect
gomplate
magic-wormhole
tftp-hpa
nettools
unixtools.ping
iperf3
ncurses
ncurses.dev
pkg-config
gcc
stdenv
scale-network.serverspec
];

networkSub = with pkgs; [
perl
ghostscript
];
in
{
scalePython = pkgs.mkShellNoCC {
packages = scalePython;
};

global = pkgs.mkShellNoCC {
packages = global;
};

openwrtSub = pkgs.mkShellNoCC {
packages = openwrtSub;
};

networkSub = pkgs.mkShellNoCC {
packages = networkSub;
};

default = pkgs.mkShellNoCC {
packages = (scalePython ++ global ++ openwrtSub ++ networkSub);
};
}
)
Loading