What seems to be a workable config

This commit is contained in:
Olaf
2025-05-07 11:46:07 +02:00
parent fbd41a72f1
commit 62d004a6a2
13 changed files with 638 additions and 62 deletions

135
flake.nix
View File

@ -1,9 +1,18 @@
{
description = "Starter Configuration with secrets for MacOS and NixOS";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
agenix.url = "github:ryantm/agenix";
home-manager.url = "github:nix-community/home-manager";
nixpkgs = {
url = "github:nixos/nixpkgs/nixos-unstable";
};
agenix = {
url = "github:ryantm/agenix";
};
home-manager = {
url = "github:nix-community/home-manager";
};
nixd = {
url = "github:nix-community/nixd";
};
darwin = {
url = "github:LnL7/nix-darwin/master";
inputs.nixpkgs.follows = "nixpkgs";
@ -22,34 +31,75 @@
homebrew-cask = {
url = "github:homebrew/homebrew-cask";
flake = false;
};
};
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
};
secrets = {
url = "git@git.kolkman.org:olaf/nix-config-secrets.git";
flake = false;
};
};
outputs = { self, darwin, nix-homebrew, homebrew-bundle, homebrew-core, homebrew-cask, home-manager, nixpkgs, disko, agenix } @inputs:
outputs =
{
self,
darwin,
nix-homebrew,
homebrew-bundle,
homebrew-core,
homebrew-cask,
home-manager,
nixpkgs,
disko,
agenix,
secrets,
nixd,
}@inputs:
let
user = "%USER%";
linuxSystems = [ "x86_64-linux" "aarch64-linux" ];
darwinSystems = [ "aarch64-darwin" "x86_64-darwin" ];
user = "olaf";
linuxSystems = [
"x86_64-linux"
"aarch64-linux"
];
darwinSystems = [
"aarch64-darwin"
"x86_64-darwin"
];
forAllSystems = f: nixpkgs.lib.genAttrs (linuxSystems ++ darwinSystems) f;
devShell = system: let pkgs = nixpkgs.legacyPackages.${system}; in {
default = with pkgs; mkShell {
nativeBuildInputs = with pkgs; [ bashInteractive git age age-plugin-yubikey ];
shellHook = with pkgs; ''
export EDITOR=vim
'';
devShell =
system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
default =
with pkgs;
mkShell {
nativeBuildInputs = with pkgs; [
bashInteractive
git
age
age-plugin-yubikey
];
shellHook = with pkgs; ''
export EDITOR=vim
'';
buildInputs = with pkgs; [
rnix-lsp
];
};
};
};
mkApp = scriptName: system: {
type = "app";
program = "${(nixpkgs.legacyPackages.${system}.writeScriptBin scriptName ''
#!/usr/bin/env bash
PATH=${nixpkgs.legacyPackages.${system}.git}/bin:$PATH
echo "Running ${scriptName} for ${system}"
exec ${self}/apps/${system}/${scriptName}
'')}/bin/${scriptName}";
program = "${
(nixpkgs.legacyPackages.${system}.writeScriptBin scriptName ''
#!/usr/bin/env bash
PATH=${nixpkgs.legacyPackages.${system}.git}/bin:$PATH
echo "Running ${scriptName} for ${system}"
exec ${self}/apps/${system}/${scriptName}
'')
}/bin/${scriptName}";
};
mkLinuxApps = system: {
"apply" = mkApp "apply" system;
@ -72,9 +122,12 @@
in
{
devShells = forAllSystems devShell;
apps = nixpkgs.lib.genAttrs linuxSystems mkLinuxApps // nixpkgs.lib.genAttrs darwinSystems mkDarwinApps;
apps =
nixpkgs.lib.genAttrs linuxSystems mkLinuxApps
// nixpkgs.lib.genAttrs darwinSystems mkDarwinApps;
darwinConfigurations = nixpkgs.lib.genAttrs darwinSystems (system:
darwinConfigurations = nixpkgs.lib.genAttrs darwinSystems (
system:
darwin.lib.darwinSystem {
inherit system;
specialArgs = inputs;
@ -99,20 +152,24 @@
}
);
nixosConfigurations = nixpkgs.lib.genAttrs linuxSystems (system: nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = inputs;
modules = [
disko.nixosModules.disko
home-manager.nixosModules.home-manager {
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
users.${user} = import ./modules/nixos/home-manager.nix;
};
}
./hosts/nixos
];
});
};
nixosConfigurations = nixpkgs.lib.genAttrs linuxSystems (
system:
nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = inputs;
modules = [
disko.nixosModules.disko
home-manager.nixosModules.home-manager
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
users.${user} = import ./modules/nixos/home-manager.nix;
};
}
./hosts/nixos
];
}
);
};
}