Something went wrong. Try again.
This string has no description
Something went wrong. Try again.
2.1 kB · 73 lines · Created 2mo ago
Nix
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374# Inspired by https://github.com/sini/nix-config/blob/98d4a67/modules/den/schema/host.nix{ lib, inputs, ... }:let channels = { stable = { nixosSystem = inputs.nixpkgs.lib.nixosSystem; darwinSystem = inputs.darwin.lib.darwinSystem; homeManager = { nixos = inputs.home-manager.nixosModules.home-manager; darwin = inputs.home-manager.darwinModules.home-manager; }; };
unstable = { nixosSystem = inputs.nixpkgs-unstable.lib.nixosSystem; darwinSystem = inputs.darwin-unstable.lib.darwinSystem; homeManager = { nixos = inputs.home-manager-unstable.nixosModules.home-manager; darwin = inputs.home-manager-unstable.darwinModules.home-manager; }; }; };in{ flake-file.inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-26.05"; nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
darwin = { url = "github:nix-darwin/nix-darwin/nix-darwin-26.05"; inputs.nixpkgs.follows = "nixpkgs"; }; darwin-unstable = { url = "github:nix-darwin/nix-darwin"; inputs.nixpkgs.follows = "nixpkgs-unstable"; };
home-manager = { url = "github:nix-community/home-manager/release-26.05"; inputs.nixpkgs.follows = "nixpkgs"; }; home-manager-unstable = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs-unstable"; }; };
den.schema.host.imports = [ ({ config, ... }: { options.channel = lib.mkOption { type = lib.types.enum (builtins.attrNames channels); default = "stable"; };
config = let resolvedChannel = channels.${config.channel}; in { instantiate = lib.mkDefault ( if config.class == "darwin" then resolvedChannel.darwinSystem else resolvedChannel.nixosSystem );
home-manager.module = lib.mkDefault ( if config.class == "darwin" then resolvedChannel.homeManager.darwin else resolvedChannel.homeManager.nixos ); }; }) ];}