diff options
author | Azat Bahawi <azat@bahawi.net> | 2023-11-13 10:40:41 +0300 |
---|---|---|
committer | Azat Bahawi <azat@bahawi.net> | 2023-11-13 10:40:41 +0300 |
commit | a3f9fde2a2d43dd477f402bd4b8df2a1cd29ca43 (patch) | |
tree | cbd0c2457daa6865eb33b5389ec40309e60868a9 /flake.nix | |
parent | 2023-11-12 (diff) |
2023-11-13
Diffstat (limited to '')
-rw-r--r-- | flake.nix | 130 |
1 files changed, 33 insertions, 97 deletions
diff --git a/flake.nix b/flake.nix index 49a3527..558ccfb 100644 --- a/flake.nix +++ b/flake.nix @@ -1,8 +1,8 @@ { - description = "nixfiles"; + description = "azahi's NixOS/nix-darwin/home-manager den"; - # `flake.lock` generation is not computable[1], thus it is impossible to add - # helper functions to manage inputs. + # The `flake.lock` generation is not computable[1]. So far it's impossible to + # add helper functions to manage inputs. # # [1]: https://github.com/NixOS/nix/issues/5373 inputs = { @@ -15,6 +15,11 @@ ref = "nixpkgs-unstable"; }; + # nixpkgs-local = { + # type = "path"; + # path = "/home/azahi/src/nixpkgs"; + # }; + nixpkgs-master = { type = "github"; owner = "NixOS"; @@ -29,12 +34,6 @@ ref = "release-23.05"; }; - # For testing PRs and stuff. - # nixpkgs-local = { - # type = "path"; - # path = "/home/azahi/src/nixpkgs"; - # }; - nixos-hardware = { type = "github"; owner = "NixOS"; @@ -254,107 +253,44 @@ lib = nixpkgs.lib.extend (import ./lib); in flake-utils.lib.eachDefaultSystem - (system: let - pkgs = import nixpkgs { + (system: { + apps.default = { + type = "app"; + program = "${self.packages.${system}.default}/bin/nixfiles"; + }; + + packages = with lib; let + buildIsoImage = name: self.nixosConfigurations.${name}.config.system.build.isoImage; + in { + default = self.legacyPackages.${system}.nixfiles; + iso-arm = buildIsoImage "iso-arm"; + iso-x86 = buildIsoImage "iso-x86"; + }; + + legacyPackages = import nixpkgs { inherit system; overlays = [self.overlays.default]; }; - in { - packages = with lib; - pkgs - // (mapAttrs (_: c: c.config.system.build.toplevel) - (builtins.removeAttrs self.nixosConfigurations ["iso-arm" "iso-x86"])) - // (let - buildIsoImage = name: self.nixosConfigurations.${name}.config.system.build.isoImage; - in { - iso-arm = buildIsoImage "iso-arm"; - iso-x86 = buildIsoImage "iso-x86"; - }) - // { - default = pkgs.nixfiles; - }; - - apps.${system}.default = { - type = "app"; - package = "${self.packages.${system}.default}/bin/nixfiles"; - }; - devShells.default = pkgs.mkShell { + devShells.default = self.legacyPackages.${system}.mkShell { inherit (self.checks.${system}.preCommit) shellHook; - # TODO Figure out why direnv overwrites exec-path. Meanwhile leave - # this in devShell. - packages = with pkgs; [nil]; }; - formatter = with pkgs; - writeShellScriptBin "fmt" '' - ${alejandra}/bin/alejandra --quiet "$@" - ''; - - checks.preCommit = pre-commit-hooks.lib.${system}.run { - src = builtins.path { - name = "nixfiles"; - path = ./.; - }; - hooks = { - alejandra.enable = true; - deadnix.enable = true; - editorconfig-checker.enable = true; - prettier = { - enable = true; - files = "\\.css"; - }; - shellcheck.enable = true; - shfmt.enable = true; - statix.enable = true; - typos = { - enable = true; - types = ["text"]; - pass_filenames = false; - }; - yamllint.enable = true; - promtool = { - enable = true; - name = "promtool"; - description = "Check Prometheus rules"; - entry = "${pkgs.prometheus.cli}/bin/promtool check rules"; - files = "(?x)^(modules/nixos/monitoring/rules/.*\.yaml)$"; - }; - }; - settings.deadnix.edit = true; - }; + formatter = self.legacyPackages.${system}.alejandra; + + checks = import ./checks.nix {inherit system inputs lib;}; }) - // (let - importConfigurations = dir: import dir {inherit inputs lib;}; - in { + // { inherit lib; modules.nixfiles = import ./modules/common; nixosModules.nixfiles = import ./modules/nixos; - nixosConfigurations = importConfigurations ./nixosConfigurations; + nixosConfigurations = import ./nixosConfigurations {inherit inputs lib;}; darwinModules.nixfiles = import ./modules/darwin; - darwinConfigurations = importConfigurations ./darwinConfigurations; - - overlays.default = final: prev: { - bruh = prev.callPackage ./packages/bruh.nix {}; - hiccup = prev.callPackage ./packages/hiccup.nix {}; - mpv-autosub = prev.callPackage ./packages/mpv-autosub.nix {}; - myip = prev.callPackage ./packages/myip.nix {}; - nixfiles = prev.callPackage ./packages/nixfiles.nix {}; - openssl_1_0_0 = prev.callPackage ./packages/openssl_1_0_0.nix {}; - logcli = prev.grafana-loki.overrideAttrs (_: super: { - pname = "logcli"; - subPackages = ["cmd/logcli"]; - nativeBuildInputs = super.nativeBuildInputs ++ [final.installShellFiles]; - postInstall = '' - installShellCompletion --cmd logcli \ - --bash <($out/bin/logcli --completion--script-bash) \ - --zsh <($out/bin/logcli --completion-script-zsh) - ''; - preFixup = null; - }); - }; - }); + darwinConfigurations = import ./darwinConfigurations {inherit inputs lib;}; + + overlays.default = final: prev: import ./overlays.nix final prev; + }; } |