refactor(flake.nix): Use flake-parts to simplify flake.nix
This commit is contained in:
parent
f7a64063bb
commit
10e72d3c19
10 changed files with 380 additions and 271 deletions
139
flake.nix
139
flake.nix
|
|
@ -1,8 +1,7 @@
|
|||
{
|
||||
description = "tlater.net host configuration";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "https://channels.nixos.org/nixos-25.11/nixexprs.tar.xz";
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
|
||||
## Nix/OS utilities
|
||||
|
||||
|
|
@ -42,139 +41,49 @@
|
|||
crate2nix.inputs = {
|
||||
flake-compat.follows = "deploy-rs/flake-compat";
|
||||
devshell.inputs.flake-utils.follows = "deploy-rs/utils";
|
||||
flake-parts.follows = "flake-parts";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
outputs =
|
||||
{
|
||||
self,
|
||||
nixpkgs,
|
||||
sops-nix,
|
||||
...
|
||||
}@inputs:
|
||||
let
|
||||
system = "x86_64-linux";
|
||||
|
||||
vm = nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
specialArgs.flake-inputs = inputs;
|
||||
|
||||
modules = [
|
||||
./configuration
|
||||
./configuration/hardware-specific/vm.nix
|
||||
{ flake-parts, ... }@inputs:
|
||||
flake-parts.lib.mkFlake { inherit inputs; } (
|
||||
{ self, ... }@args:
|
||||
{
|
||||
imports = [
|
||||
(flake-parts.lib.importApply ./flakeModules/deploy-rs.nix args)
|
||||
./checks
|
||||
./dev-utils.nix
|
||||
./pkgs
|
||||
];
|
||||
};
|
||||
|
||||
# deploy-rs unfortunately uses an `import nixpkgs`, and its
|
||||
# library functions depend on an instantiated nixpkgs, so we
|
||||
# can't get around multi-nixpkgs-eval.
|
||||
inherit
|
||||
(import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [
|
||||
inputs.deploy-rs.overlays.default
|
||||
(_: prev: {
|
||||
deploy-rs = {
|
||||
inherit (nixpkgs.legacyPackages.${system}) deploy-rs;
|
||||
inherit (prev.deploy-rs) lib;
|
||||
};
|
||||
})
|
||||
];
|
||||
})
|
||||
deploy-rs
|
||||
;
|
||||
in
|
||||
{
|
||||
##################
|
||||
# Configurations #
|
||||
##################
|
||||
nixosConfigurations = {
|
||||
# The actual system definition
|
||||
hetzner-1 = nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
flake.nixosConfigurations.hetzner-1 = inputs.nixpkgs.lib.nixosSystem {
|
||||
specialArgs.flake-inputs = inputs;
|
||||
|
||||
modules = [
|
||||
./configuration
|
||||
./configuration/hardware-specific/hetzner
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
############################
|
||||
# Deployment configuration #
|
||||
############################
|
||||
deploy.nodes = {
|
||||
hetzner-1 = {
|
||||
deploy.nodes.hetzner-1 = {
|
||||
hostname = "116.202.158.55";
|
||||
|
||||
profiles.system = {
|
||||
user = "root";
|
||||
path = deploy-rs.lib.activate.nixos self.nixosConfigurations.hetzner-1;
|
||||
activation = "nixos";
|
||||
closure = self.nixosConfigurations.hetzner-1;
|
||||
|
||||
sshUser = "tlater";
|
||||
sshOpts = [
|
||||
"-p"
|
||||
"2222"
|
||||
"-o"
|
||||
"ForwardAgent=yes"
|
||||
];
|
||||
};
|
||||
|
||||
sshUser = "tlater";
|
||||
sshOpts = [
|
||||
"-p"
|
||||
"2222"
|
||||
"-o"
|
||||
"ForwardAgent=yes"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
#########
|
||||
# Tests #
|
||||
#########
|
||||
checks = import ./checks { flake-inputs = inputs; };
|
||||
|
||||
###########################
|
||||
# Garbage collection root #
|
||||
###########################
|
||||
|
||||
packages.${system} = {
|
||||
default = vm.config.system.build.vm;
|
||||
}
|
||||
// import ./pkgs { pkgs = nixpkgs.legacyPackages.${system}; };
|
||||
|
||||
###################
|
||||
# Utility scripts #
|
||||
###################
|
||||
apps.${system} = {
|
||||
default = self.apps.${system}.run-vm;
|
||||
|
||||
run-vm = {
|
||||
type = "app";
|
||||
program =
|
||||
(nixpkgs.legacyPackages.${system}.writeShellScript "" ''
|
||||
${vm.config.system.build.vm.outPath}/bin/run-testvm-vm
|
||||
'').outPath;
|
||||
};
|
||||
};
|
||||
|
||||
###########################
|
||||
# Development environment #
|
||||
###########################
|
||||
devShells.${system} = {
|
||||
default = nixpkgs.legacyPackages.${system}.mkShell {
|
||||
sopsPGPKeyDirs = [
|
||||
"./keys/hosts/"
|
||||
"./keys/users/"
|
||||
];
|
||||
|
||||
packages = nixpkgs.lib.attrValues {
|
||||
inherit (sops-nix.packages.${system}) sops-import-keys-hook sops-init-gpg-key;
|
||||
inherit (deploy-rs) deploy-rs;
|
||||
};
|
||||
};
|
||||
|
||||
minecraft = nixpkgs.legacyPackages.${system}.mkShell {
|
||||
packages = nixpkgs.lib.attrValues { inherit (nixpkgs.legacyPackages.${system}) packwiz; };
|
||||
};
|
||||
|
||||
webserver = self.packages.${system}.webserver.devShell;
|
||||
};
|
||||
};
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue