Restructure flake

This commit is contained in:
Natsu Kagami 2023-04-18 13:03:19 +02:00
parent eb80947e01
commit 0ec27dd717
Signed by: nki
GPG key ID: 7306B3D3C3AD6E51
4 changed files with 58 additions and 51 deletions

View file

@ -16,10 +16,11 @@ with lib; {
./modules/common/linux ./modules/common/linux
./modules/my-tinc ./modules/my-tinc
]; ];
# swaync disable notifications on screencast
config.xdg.portal.wlr.settings.screencast = {
exec_before = ''which swaync-client && swaync-client --inhibitor-add "xdg-desktop-portal-wlr" || true'';
exec_after = ''which swaync-client && swaync-client --inhibitor-remove "xdg-desktop-portal-wlr" || true'';
};
## Packages
# Nix options
# Always have flakes enabled!
nix.extraOptions = ''
experimental-features = nix-command flakes repl-flake
'';
} }

View file

@ -351,11 +351,11 @@
"rust-overlay": "rust-overlay_2" "rust-overlay": "rust-overlay_2"
}, },
"locked": { "locked": {
"lastModified": 1677216540, "lastModified": 1679451428,
"narHash": "sha256-t7vsvKalN24LUrIABHk3OlzpXhrTfS40AdP6whv3C9I=", "narHash": "sha256-Xk3WBlejWUpnuOnMZzTH7mV/bTRxKIrln871ba3uQjI=",
"owner": "tpwrules", "owner": "tpwrules",
"repo": "nixos-apple-silicon", "repo": "nixos-apple-silicon",
"rev": "e79177006306ae592bc865b03667af4229620461", "rev": "696d7b4ac7ca05684a3cceedd44acfd0d1c5f1e3",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -398,15 +398,15 @@
}, },
"nixpkgs-unstable": { "nixpkgs-unstable": {
"locked": { "locked": {
"lastModified": 1681215634, "lastModified": 1681740123,
"narHash": "sha256-dI0SsSWb7ksK3OtTCf61vdlBhok838aIpwQ2EUM+jhY=", "narHash": "sha256-RrcHEqm+f04nFpQQSnsGsUhJb2mNuqfdcGWL2DREEaY=",
"owner": "nixos", "owner": "natsukagami",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "5a156c2e89c1eca09b40bcdcee86760e0e4d79a9", "rev": "55325c13e8f5c06a57a210b30a19b2fbebe185f1",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "nixos", "owner": "natsukagami",
"ref": "nixpkgs-unstable", "ref": "nixpkgs-unstable",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
@ -595,11 +595,11 @@
"flake-utils": "flake-utils_4" "flake-utils": "flake-utils_4"
}, },
"locked": { "locked": {
"lastModified": 1669915544, "lastModified": 1681814227,
"narHash": "sha256-wByoZ+HWXo7L9QyUefMhe26IUUeFGtffG6v/AL31neo=", "narHash": "sha256-YQET7Vnnc6f8k2M2YhKbflFSPFfdgpVCn7xFYiMLPTE=",
"ref": "refs/heads/master", "ref": "refs/heads/master",
"rev": "9142ca82ec1e9a6e1314d2727cdc15db30c94c14", "rev": "a810d3209929ec0a44efdc2171b92f3723bb8a6a",
"revCount": 4, "revCount": 5,
"type": "git", "type": "git",
"url": "ssh://git@github.com/natsukagami/nix-deploy-secrets" "url": "ssh://git@github.com/natsukagami/nix-deploy-secrets"
}, },

View file

@ -3,7 +3,7 @@
inputs = { inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.11"; nixpkgs.url = "github:nixos/nixpkgs/nixos-22.11";
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixpkgs-unstable"; nixpkgs-unstable.url = "github:natsukagami/nixpkgs/nixpkgs-unstable";
# nixpkgs-unstable.follows = "nixos-m1/nixpkgs"; # nixpkgs-unstable.follows = "nixos-m1/nixpkgs";
darwin.url = "github:lnl7/nix-darwin/master"; darwin.url = "github:lnl7/nix-darwin/master";
darwin.inputs.nixpkgs.follows = "nixpkgs-unstable"; darwin.inputs.nixpkgs.follows = "nixpkgs-unstable";
@ -52,11 +52,15 @@
outputs = { self, darwin, nixpkgs, nixpkgs-unstable, home-manager, deploy-rs, sops-nix, nur, ... }@inputs: outputs = { self, darwin, nixpkgs, nixpkgs-unstable, home-manager, deploy-rs, sops-nix, nur, ... }@inputs:
let let
overlays = import ./overlay.nix inputs; overlays = import ./overlay.nix inputs;
lib = nixpkgs.lib;
pkgs' = system: import nixpkgs { inherit system overlays; config.allowUnfree = true; }; applyOverlays = { ... }: {
pkgs-unstable = system: import nixpkgs-unstable { inherit system overlays; config.allowUnfree = true; }; nixpkgs.overlays = lib.mkBefore overlays;
};
nixpkgsAsRegistry_ = stable: { ... }: { nixpkgsAsRegistry_ = stable: { lib, ... }: {
imports = [ applyOverlays ];
nix.registry.current-system.flake = self;
nix.registry.nixpkgs.flake = stable; nix.registry.nixpkgs.flake = stable;
nix.registry.nixpkgs-unstable.flake = nixpkgs-unstable; nix.registry.nixpkgs-unstable.flake = nixpkgs-unstable;
nix.nixPath = [ nix.nixPath = [
@ -64,10 +68,6 @@
"nixpkgs-unstable=${nixpkgs-unstable}" "nixpkgs-unstable=${nixpkgs-unstable}"
"/nix/var/nix/profiles/per-user/root/channels" "/nix/var/nix/profiles/per-user/root/channels"
]; ];
};
nixpkgsAsRegistry = nixpkgsAsRegistry_ nixpkgs;
haskellDotNix = { ... }: {
# Binary Cache for Haskell.nix # Binary Cache for Haskell.nix
nix.settings.trusted-public-keys = [ nix.settings.trusted-public-keys = [
"hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ="
@ -76,6 +76,22 @@
"https://cache.iog.io" "https://cache.iog.io"
]; ];
}; };
nixpkgsAsRegistry = nixpkgsAsRegistry_ nixpkgs;
# Common Nix modules
common-nix = stable: { ... }: {
imports = [
(nixpkgsAsRegistry_ stable)
./common.nix
sops-nix.nixosModules.sops
];
};
common-nixos = stable: { ... }: {
imports = [
(common-nix stable)
inputs.secrets.nixosModules.common
];
};
enableOsuStable = { lib, ... }: { enableOsuStable = { lib, ... }: {
imports = [ inputs.nix-gaming.nixosModules.pipewireLowLatency ]; imports = [ inputs.nix-gaming.nixosModules.pipewireLowLatency ];
@ -98,15 +114,14 @@
}; };
in in
{ {
overlays.default = lib.composeManyExtensions overlays;
# MacBook configuration: nix-darwin + home-manager # MacBook configuration: nix-darwin + home-manager
darwinConfigurations."nki-macbook" = darwin.lib.darwinSystem rec { darwinConfigurations."nki-macbook" = darwin.lib.darwinSystem rec {
system = "aarch64-darwin"; system = "aarch64-darwin";
pkgs = pkgs-unstable system;
modules = [ modules = [
(common-nix nixpkgs-unstable)
./darwin/configuration.nix ./darwin/configuration.nix
# Set nix path
haskellDotNix
(nixpkgsAsRegistry_ nixpkgs-unstable)
inputs.home-manager-unstable.darwinModules.home-manager inputs.home-manager-unstable.darwinModules.home-manager
{ {
home-manager.useGlobalPkgs = true; home-manager.useGlobalPkgs = true;
@ -119,12 +134,9 @@
# Home configuration # Home configuration
nixosConfigurations."nki-home" = nixpkgs.lib.nixosSystem rec { nixosConfigurations."nki-home" = nixpkgs.lib.nixosSystem rec {
system = "x86_64-linux"; system = "x86_64-linux";
pkgs = pkgs' system;
modules = [ modules = [
./common.nix (common-nixos nixpkgs)
sops-nix.nixosModules.sops
./nki-home/configuration.nix ./nki-home/configuration.nix
nixpkgsAsRegistry
enableOsuStable enableOsuStable
home-manager.nixosModules.home-manager home-manager.nixosModules.home-manager
{ {
@ -137,17 +149,14 @@
]; ];
}; };
} }
inputs.secrets.nixosModules.x86_64-linux.common
]; ];
}; };
# x1c1 configuration # x1c1 configuration
nixosConfigurations."nki-x1c1" = nixpkgs.lib.nixosSystem rec { nixosConfigurations."nki-x1c1" = nixpkgs.lib.nixosSystem rec {
pkgs = pkgs' system;
system = "x86_64-linux"; system = "x86_64-linux";
modules = [ modules = [
sops-nix.nixosModules.sops (common-nixos nixpkgs)
./nki-x1c1/configuration.nix ./nki-x1c1/configuration.nix
nixpkgsAsRegistry
home-manager.nixosModules.home-manager home-manager.nixosModules.home-manager
{ {
home-manager.useGlobalPkgs = true; home-manager.useGlobalPkgs = true;
@ -158,32 +167,27 @@
}; };
# macbook nixos # macbook nixos
nixosConfigurations."kagami-air-m1" = nixpkgs-unstable.lib.nixosSystem rec { nixosConfigurations."kagami-air-m1" = nixpkgs-unstable.lib.nixosSystem rec {
pkgs = pkgs-unstable system;
system = "aarch64-linux"; system = "aarch64-linux";
modules = [ modules = [
./common.nix (common-nixos nixpkgs)
sops-nix.nixosModules.sops
inputs.nixos-m1.nixosModules.apple-silicon-support inputs.nixos-m1.nixosModules.apple-silicon-support
./kagami-air-m1/configuration.nix ./kagami-air-m1/configuration.nix
nixpkgsAsRegistry
inputs.home-manager-unstable.nixosModules.home-manager inputs.home-manager-unstable.nixosModules.home-manager
{ {
home-manager.useGlobalPkgs = true; home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true; home-manager.useUserPackages = true;
home-manager.users.nki = import ./home/macbook-nixos.nix; home-manager.users.nki = import ./home/macbook-nixos.nix;
} }
inputs.secrets.nixosModules.${system}.common
]; ];
}; };
# DigitalOcean node # DigitalOcean node
nixosConfigurations."nki-personal-do" = nixpkgs.lib.nixosSystem rec { nixosConfigurations."nki-personal-do" = nixpkgs.lib.nixosSystem rec {
pkgs = pkgs' system;
system = "x86_64-linux"; system = "x86_64-linux";
modules = [ modules = [
(common-nixos nixpkgs)
./modules/my-tinc ./modules/my-tinc
inputs.youmubot.nixosModule.x86_64-linux inputs.youmubot.nixosModule.x86_64-linux
sops-nix.nixosModules.sops
./nki-personal-do/configuration.nix ./nki-personal-do/configuration.nix
inputs.secrets.nixosModules.x86_64-linux.nki-personal-do inputs.secrets.nixosModules.x86_64-linux.nki-personal-do
]; ];

View file

@ -19,10 +19,18 @@ let
networkConfig.DHCP = "yes"; networkConfig.DHCP = "yes";
}; };
}; };
wlr = { ... }: mkIf config.common.linux.enable {
# swaync disable notifications on screencast
xdg.portal.wlr.settings.screencast = {
exec_before = ''which swaync-client && swaync-client --inhibitor-add "xdg-desktop-portal-wlr" || true'';
exec_after = ''which swaync-client && swaync-client --inhibitor-remove "xdg-desktop-portal-wlr" || true'';
};
};
}; };
in in
{ {
imports = with modules; [ adb ios ]; imports = with modules; [ adb ios wlr ];
options.common.linux = { options.common.linux = {
enable = mkOption { enable = mkOption {
@ -165,12 +173,6 @@ in
]; ];
}; };
## Packages
# Nix options
# Always have flakes enabled!
nix.extraOptions = ''
experimental-features = nix-command flakes
'';
# Default packages # Default packages
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
kakoune # An editor kakoune # An editor