nixos-config/flake.nix

252 lines
7.2 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
# -------
2022-09-23 20:29:18 +02:00
colmena = {
url = "github:zhaofengli/colmena";
inputs.nixpkgs.follows = "nixpkgs";
};
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 = {
2022-10-12 16:58:38 +02:00
url = "github:nix-community/home-manager/release-22.05";
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;
};
2022-09-29 12:36:36 +02:00
retiolum = {
url = "github:krebs/retiolum";
flake = false;
};
2022-10-22 15:01:11 +02:00
thinkpad-dock = {
url = "github:oxzi/nixos-thinkpad-dock";
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
2022-09-29 12:36:36 +02:00
, retiolum
2022-10-22 15:01:11 +02:00
, thinkpad-dock
}:
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 = {
2022-09-29 12:36:36 +02:00
inherit private_assets retiolum;
2022-06-23 00:33:59 +02:00
};
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 = [
2022-06-26 12:54:13 +02:00
nixpkgs-fmt.defaultPackage.${system}
colmena.packages.${system}.colmena
2022-06-23 00:33:59 +02:00
];
imports = [
2022-09-20 21:48:36 +02:00
./nixos/machines/${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, ... }: {
2022-09-20 20:08:53 +02:00
deployment.allowLocalDeployment = true;
2022-06-23 00:33:59 +02:00
deployment.targetHost = "${name}.private";
2022-09-23 20:29:18 +02:00
deployment.tags = [ "desktop" "online" "private" ];
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-09-23 20:29:18 +02:00
deployment.tags = [ "server" "online" "private" ];
imports = [
2022-06-23 00:33:59 +02:00
grocy-scanner.nixosModule
];
};
2022-06-23 00:53:29 +02:00
robi = { name, nodes, pkgs, ... }: {
2022-10-19 13:16:24 +02:00
deployment.targetHost = "${name}.private";
2022-09-23 20:29:18 +02:00
deployment.tags = [ "server" "online" "private" ];
2022-06-23 00:53:29 +02:00
imports = [ ];
};
2022-10-19 13:16:24 +02:00
bobi = { name, nodes, pkgs, ... }: {
#deployment.targetHost = "${name}.private";
deployment.targetHost = "localhost";
deployment.targetPort = 2222;
deployment.tags = [ "desktop" "usb" "private" ];
imports = [
grocy-scanner.nixosModule
];
home-manager.users.mainUser = {
imports = [
doom-emacs-nix.hmModule
home-manager-utils.hmModule
];
};
};
2022-09-23 20:29:18 +02:00
mobi = { name, nodes, pkgs, ... }: {
deployment.targetHost = "${name}.private";
deployment.tags = [ "desktop" "usb" "private" ];
imports = [
grocy-scanner.nixosModule
];
home-manager.users.mainUser = {
imports = [
doom-emacs-nix.hmModule
home-manager-utils.hmModule
];
};
};
};
2021-09-25 20:28:25 +02:00
};
2021-09-24 06:09:20 +02:00
}