nixos-config/flake.nix

208 lines
5.9 KiB
Nix
Raw Normal View History

2021-09-24 06:09:20 +02:00
{
description = "my krops file";
inputs = {
2021-09-25 11:07:09 +02:00
secrets = {
2022-01-15 09:32:59 +01:00
url = "git+ssh://gitea@git.ingolf-wagner.de/palo/nixos-secrets.git?ref=main";
2021-09-25 11:07:09 +02:00
flake = false;
};
2022-06-14 22:56:58 +02:00
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.05";
2021-09-24 06:09:20 +02:00
krops = {
url = "github:Mic92/krops";
inputs.nixpkgs.follows = "nixpkgs";
};
# colmena
2022-06-22 23:06:16 +02:00
# -------
colmena.url = "github:zhaofengli/colmena";
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
polygon-art = {
url = "git+https://git.ingolf-wagner.de/palo/polygon-art.git";
};
sops-nix.url = "github:Mic92/sops-nix";
emacs-overlay = {
url = "github:nix-community/emacs-overlay";
flake = false;
};
doom-emacs-nix = {
url = "github:nix-community/nix-doom-emacs";
inputs.nixpkgs.follows = "nixpkgs";
#inputs.emacs-overlay.follows = "emacs-overlay";
};
home-manager = {
url = "github:nix-community/home-manager/release-21.11";
inputs.nixpkgs.follows = "nixpkgs";
};
home-manager-utils = {
url = "github:mrvandalo/home-manager-utils";
inputs.home-manager.follows = "home-manager";
};
cluster-module = {
url = "github:mrvandalo/module.cluster";
};
nixpkgs-fmt = {
url = "github:nix-community/nixpkgs-fmt";
inputs.nixpkgs.follows = "nixpkgs";
};
grocy-scanner = {
url = "github:mrVanDalo/grocy-scanner";
inputs.nixpkgs.follows = "nixpkgs";
};
2022-06-22 23:06:16 +02:00
private_assets = {
2022-06-23 10:46:41 +02:00
url = "git+ssh://gitea@git.ingolf-wagner.de/palo/nixos-private-assets.git?ref=main";
2022-06-22 23:06:16 +02:00
flake = false;
};
2021-09-24 06:09:20 +02:00
};
outputs =
{ self
, cluster-module
, colmena
, doom-emacs-nix
, emacs-overlay
, grocy-scanner
, home-manager
, home-manager-utils
2022-06-22 23:06:16 +02:00
, krops
, nixpkgs
, nixpkgs-fmt
, nixpkgs-unstable
, polygon-art
2022-06-22 23:06:16 +02:00
, private_assets
, secrets
2022-06-22 23:06:16 +02:00
, sops-nix
}:
2021-09-25 20:28:25 +02:00
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
writeCommand = krops.packages.${system}.writeCommand;
2022-06-23 00:33:59 +02:00
pullNetworkPasswords = pkgs.writers.writeBashBin "pull-network-passwords" ''
2022-06-23 01:03:37 +02:00
# collect all network configurations and save them in the store
sudo ls /etc/NetworkManager/system-connections \
| while read file
do
sudo cat "/etc/NetworkManager/system-connections/$file" \
| ${pkgs.pass}/bin/pass insert -m "krops/desktop_secrets/network-manager/system-connections/$file"
done
2022-06-23 00:33:59 +02:00
'';
pushNetworkPasswords = pkgs.writers.writeBashBin "push-network-passwords" ''
echo "push network passwords to $1"
'';
2021-11-01 09:20:42 +01:00
in
{
# colmena
2022-06-23 00:33:59 +02:00
devShell.${system} =
pkgs.mkShell {
2022-06-23 00:33:59 +02:00
buildInputs = [
colmena.packages.${system}.colmena
pushNetworkPasswords
pullNetworkPasswords
nixpkgs-fmt.defaultPackage.${system}
];
};
2022-06-23 00:33:59 +02:00
colmena =
let
sopsModule = name: { lib, ... }: {
sops.defaultSopsFile = lib.mkForce "${secrets}/secrets/${name}.yaml";
imports = [
sops-nix.nixosModules.sops
];
};
2022-06-23 00:33:59 +02:00
in
{
meta = {
nixpkgs = import nixpkgs {
system = "x86_64-linux";
overlays = [
(_self: _super: {
# we assign the overlay created before to the overlays of nixpkgs.
unstable = nixpkgs-unstable.legacyPackages.${pkgs.system};
polygon-art = polygon-art.packages.${pkgs.system};
})
];
};
specialArgs = {
inherit private_assets;
};
2022-06-22 23:06:16 +02:00
};
2022-06-23 00:33:59 +02:00
defaults = { name, pkgs, ... }: {
deployment.buildOnTarget = true;
nix = {
# no channesl needed this way
nixPath = [ "nixpkgs=${pkgs.path}" ];
# make flakes available
package = pkgs.nixUnstable;
extraOptions = ''
experimental-features = nix-command flakes
'';
};
2022-06-23 00:33:59 +02:00
environment.systemPackages = [
nixpkgs-fmt.defaultPackage."x86_64-linux"
];
imports = [
2022-06-23 00:53:29 +02:00
./nixos/configs/${name}/configuration.nix
2022-06-23 00:33:59 +02:00
cluster-module.nixosModules.tinc
(sopsModule name)
home-manager.nixosModules.home-manager
];
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
};
2022-06-23 00:33:59 +02:00
sterni = { name, nodes, pkgs, ... }: {
deployment.targetHost = "${name}.private";
2022-06-23 09:51:30 +02:00
deployment.tags = [ "desktop" "online" ];
2022-06-23 00:33:59 +02:00
imports = [
grocy-scanner.nixosModule
];
home-manager.users.mainUser = {
imports = [
doom-emacs-nix.hmModule
home-manager-utils.hmModule
];
};
};
2022-06-23 00:33:59 +02:00
2022-06-23 08:39:18 +02:00
sternchen = { name, nodes, pkgs, ... }: {
deployment.targetHost = "${name}.secret";
deployment.tags = [ "desktop" ];
imports = [
grocy-scanner.nixosModule
];
home-manager.users.mainUser = {
imports = [
doom-emacs-nix.hmModule
home-manager-utils.hmModule
];
2022-06-23 09:51:30 +02:00
programs.doom-emacs.enable = false;
2022-06-23 08:39:18 +02:00
};
};
2022-06-23 00:33:59 +02:00
pepe = { name, nodes, pkgs, ... }: {
deployment.targetHost = "${name}.private";
2022-06-23 09:51:30 +02:00
deployment.tags = [ "server" "online" ];
imports = [
2022-06-23 00:33:59 +02:00
grocy-scanner.nixosModule
];
};
2022-06-23 00:53:29 +02:00
robi = { name, nodes, pkgs, ... }: {
deployment.targetHost = "${name}";
2022-06-23 09:51:30 +02:00
deployment.tags = [ "server" "online" ];
2022-06-23 00:53:29 +02:00
imports = [ ];
};
};
2021-09-25 20:28:25 +02:00
};
2021-09-24 06:09:20 +02:00
}