feat: split off outputs

This commit is contained in:
Ranomier 2025-04-28 17:05:06 +02:00
parent 7f094b80c5
commit dc411c006e
5 changed files with 52 additions and 65 deletions

View file

@ -1,9 +1,5 @@
{ {
######
inputs = { inputs = {
######
#nixpkgs-old.url = "github:NixOS/nixpkgs/nixos-24.05";
# Main nix package repository # Main nix package repository
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
@ -28,59 +24,5 @@
nix-flatpak.url = "github:gmodena/nix-flatpak"; nix-flatpak.url = "github:gmodena/nix-flatpak";
}; };
####### outputs = {...}@inArgs: import ./outputs.nix inArgs;
outputs =
#######
{
self,
nixpkgs,
nixos-hardware,
nixos-unstable,
nix-flatpak,
home-manager,
nixos-generators,
...
} @ inputs: let
# Supported systems for your flake packages, shell, etc.
systems = [
#"aarch64-linux"
"x86_64-linux"
];
# This is a function that generates an attribute by calling a function you
# pass to it, with each system as an argument
forAllSystems = nixpkgs.lib.genAttrs systems;
host_helper = hostname: {
${hostname} = nixpkgs.lib.nixosSystem {
specialArgs = {inherit inputs;};
modules = [
./hosts/${hostname}
];
};
};
in {
# Your custom packages
# Accessible through 'nix build', 'nix shell', etc
#packages = forAllSystems (system: import ./pkgs nixpkgs.legacyPackages.${system});
# Formatter for your nix files, available through 'nix fmt'
# Other options beside 'alejandra' include 'nixpkgs-fmt'
formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.alejandra);
# Your custom packages and modifications, exported as overlays
overlays = import ./overlays {inherit inputs;};
# Reusable nixos modules you might want to export
# These are usually stuff you would upstream into nixpkgs
#nixosModules = import ./modules/nixos;
# NixOS configuration entrypoint
# Available through 'nixos-rebuild --flake .#your-hostname'
# to add more append // (host_helper example);
nixosConfigurations =
host_helper "crocoite" //
host_helper "jitsi";
};
} }

9
hostHelper.nix Normal file
View file

@ -0,0 +1,9 @@
inArgs: hostname: {
${hostname} = inArgs.nixpkgs.lib.nixosSystem {
specialArgs = {inherit inArgs;};
modules = [
{networking.hostName = hostname;}
(./hosts/${hostname})
];
};
}

View file

@ -1,11 +1,11 @@
{ {
pkgs, pkgs,
inputs, inArgs,
modulesPath, modulesPath,
nixos-unstable, nixos-unstable,
... ...
}: { }: {
networking.hostName = "crocoite"; # Define your hostname. #networking.hostName = "crocoite"; # Define your hostname.
# This value determines the NixOS release from which the default # This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions # settings for stateful data, like file locations and database versions
@ -18,7 +18,7 @@
#nixpkgs.overlays = [ overlays.unstable-packages ]; #nixpkgs.overlays = [ overlays.unstable-packages ];
nixpkgs = { nixpkgs = {
# You can add overlays here # You can add overlays here
overlays = with inputs.self.overlays; [ overlays = with inArgs.self.overlays; [
# Add overlays your own flake exports (from overlays and pkgs dir): # Add overlays your own flake exports (from overlays and pkgs dir):
#additions #additions
#modifications #modifications
@ -56,7 +56,7 @@
# steam and other stuff seems to depend on perl # steam and other stuff seems to depend on perl
#"${modulesPath}/profiles/perlless.nix" #"${modulesPath}/profiles/perlless.nix"
inputs.nix-flatpak.nixosModules.nix-flatpak inArgs.nix-flatpak.nixosModules.nix-flatpak
#nixos-hardware.nixosModules.lenovo-thinkpad-t14-amd-gen1 #nixos-hardware.nixosModules.lenovo-thinkpad-t14-amd-gen1
./hardware-configuration.nix ./hardware-configuration.nix

36
outputs.nix Normal file
View file

@ -0,0 +1,36 @@
inArgs: let
# Supported systems for your flake packages, shell, etc.
systems = [
#"aarch64-linux"
"x86_64-linux"
];
# This is a function that generates an attribute by calling a function you
# pass to it, with each system as an argument
forAllSystems = inArgs.nixpkgs.lib.genAttrs systems;
hostHelper = import ./hostHelper.nix inArgs;
in {
# NixOS configuration entrypoint
# Available through 'nixos-rebuild --flake .#your-hostname'
# to add more append // (host_helper example);
nixosConfigurations =
(hostHelper "crocoite"); #// (host_helper2 "jitsi");
# Your custom packages
# Accessible through 'nix build', 'nix shell', etc
#packages = forAllSystems (system: import ./pkgs nixpkgs.legacyPackages.${system});
# Your custom packages and modifications, exported as overlays
overlays = import ./overlays {inherit inArgs;};
# Reusable nixos modules you might want to export
# These are usually stuff you would upstream into nixpkgs
#nixosModules = import ./modules/nixos;
# Formatter for your nix files, available through 'nix fmt'
# Other options beside 'alejandra' include 'nixpkgs-fmt'
formatter = forAllSystems (system: inArgs.nixpkgs.legacyPackages.${system}.alejandra);
}

View file

@ -1,5 +1,5 @@
# This file defines overlays # This file defines overlays
{inputs, ...}: { {inArgs, ...}: {
# This one brings our custom packages from the 'pkgs' directory # This one brings our custom packages from the 'pkgs' directory
additions = final: _prev: import ../pkgs final.pkgs; additions = final: _prev: import ../pkgs final.pkgs;
@ -15,7 +15,7 @@
# When applied, the unstable nixpkgs set (declared in the flake inputs) will # When applied, the unstable nixpkgs set (declared in the flake inputs) will
# be accessible through 'pkgs.unstable' # be accessible through 'pkgs.unstable'
unstable-packages = final: _prev: { unstable-packages = final: _prev: {
unstable = import inputs.nixos-unstable { unstable = import inArgs.nixos-unstable {
system = final.system; system = final.system;
config.allowUnfree = true; config.allowUnfree = true;
}; };