From 67edd7ba89d98e7534394dab674360da99f40e3d Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Mon, 4 Dec 2023 07:35:44 -0800 Subject: update to 23.11 and break down flakes Update to 23.11 for both nix and home-manager. Break down the flake in multiple parts (hosts, devshell) so that they are easier to maintain. The main reason to start this is because `nix flake check` was failing, the flake was not correct. --- flake.nix | 156 +++++++++++++------------------------------------------------- 1 file changed, 33 insertions(+), 123 deletions(-) (limited to 'flake.nix') diff --git a/flake.nix b/flake.nix index 072ad80..8994fc9 100644 --- a/flake.nix +++ b/flake.nix @@ -2,23 +2,11 @@ description = "personal NixOS configurations"; inputs = { - nixpkgs = { - type = "github"; - owner = "NixOS"; - repo = "nixpkgs"; - ref = "nixos-23.05"; - }; - - futils.url = "github:numtide/flake-utils"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11"; home-manager = { - type = "github"; - owner = "nix-community"; - repo = "home-manager"; - ref = "release-23.05"; - inputs = { - nixpkgs.follows = "nixpkgs"; - }; + url = "github:nix-community/home-manager/release-23.11"; + inputs.nixpkgs.follows = "nixpkgs"; }; darwin = { @@ -26,124 +14,46 @@ inputs.nixpkgs.follows = "nixpkgs"; }; + treefmt-nix = { + url = "github:numtide/treefmt-nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + pre-commit-hooks = { - type = "github"; - owner = "cachix"; - repo = "pre-commit-hooks.nix"; - ref = "master"; - inputs = { - flake-utils.follows = "futils"; - nixpkgs.follows = "nixpkgs"; - nixpkgs-stable.follows = "nixpkgs"; - }; + url = "github:cachix/pre-commit-hooks.nix"; + inputs.nixpkgs.follows = "nixpkgs"; }; - }; - # Output config, or config for NixOS system - outputs = inputs@{ self, darwin, home-manager, ... }: - let - myLib = import ./nix inputs; - lib = inputs.nixpkgs.lib // builtins; - supportedSystems = [ "aarch64-darwin" ]; - forAllSystems = lib.genAttrs supportedSystems; + devshell.url = "github:numtide/devshell"; - # Nixpkgs instantiated for supported system types. - nixpkgsFor = forAllSystems (system: - import inputs.nixpkgs { - inherit system; - config = { allowUnfree = true; }; - }); - in - { - templates = import ./templates; + # utils + futils.url = "github:numtide/flake-utils"; + flake-parts.url = "github:hercules-ci/flake-parts"; + }; - checks = forAllSystems (system: - let pkgs = nixpkgsFor.${system}; + # Output config, or config for NixOS system + outputs = inputs@{ self, flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + flake = + let + mba = import ./flake/mba.nix { + inherit (inputs) nixpkgs home-manager darwin; + inherit inputs; + }; in { - pre-commit-check = inputs.pre-commit-hooks.lib."${system}".run { - src = ./.; - hooks = { - nixpkgs-fmt.enable = true; - trailing-whitespace = { - enable = true; - entry = - "${pkgs.python3Packages.pre-commit-hooks}/bin/trailing-whitespace-fixer"; - types = [ "text" ]; - }; - - end-of-file-fixer = { - enable = true; - entry = - "${pkgs.python3Packages.pre-commit-hooks}/bin/end-of-file-fixer"; - types = [ "text" ]; - }; - - check-executables-have-shebangs = { - entry = - "${pkgs.python3Packages.pre-commit-hooks}/bin/check-executables-have-shebangs"; - types = [ "text" "executable" ]; - }; - - check-json = { - enable = true; - entry = "${pkgs.python3Packages.pre-commit-hooks}/bin/check-json"; - types = [ "json" ]; - }; - - check-toml = { - enable = true; - entry = "${pkgs.python3Packages.pre-commit-hooks}/bin/check-toml"; - types = [ "toml" ]; - }; - - check-yaml = { - enable = true; - entry = "${pkgs.python3Packages.pre-commit-hooks}/bin/check-yaml --allow-multiple-documents"; - types = [ "yaml" ]; - }; - - shellcheck = { - enable = true; - files = "\\.sh$"; - types_or = [ "file" ]; - }; - }; + darwinConfigurations = { + mba-fcuny = mba.system; }; - }); - - devShells = forAllSystems (system: { - default = inputs.nixpkgs.legacyPackages.${system}.mkShell { - name = "fcuny-configuration-on-${system}-system"; - buildInputs = with inputs.nixpkgs.legacyPackages.${system}.pkgs; [ - gitAndTools.pre-commit - nixfmt - nixpkgs-fmt - rnix-lsp - home-manager - git - nixos-rebuild - ]; - inherit (self.checks.${system}.pre-commit-check) shellHook; }; - }); - packages = forAllSystems (system: - let pkgs = nixpkgsFor.${system}; - in - { - inherit (inputs.futils.lib) filterPackages flattenTree; - tools = import ./tools { inherit pkgs; }; - }); + systems = [ + "aarch64-darwin" + "x86_64-linux" + ]; - darwinConfigurations = { - "mba-fcuny" = darwin.lib.darwinSystem { - system = "aarch64-darwin"; - modules = [ - home-manager.darwinModules.home-manager - ./hosts/mba - ]; - }; - }; + imports = [ + ./flake/devshell.nix + ]; }; } -- cgit v1.2.3