diff --git a/flake.lock b/flake.lock index 95d3b6e..a85b649 100644 --- a/flake.lock +++ b/flake.lock @@ -20,76 +20,29 @@ "type": "github" } }, - "dvt": { + "fenix": { "inputs": { "nixpkgs": [ + "nixpkgs-fmt", "nixpkgs" ], - "utils": "utils" + "rust-analyzer-src": "rust-analyzer-src" }, "locked": { - "lastModified": 1697793996, - "narHash": "sha256-/JcG3LEd9IqV++d0+tcLUy9NQA2jpWJ4lk6xzsYhmu8=", - "owner": "efishery", - "repo": "dvt", - "rev": "623f59e7f4226d6a5f3367ebd8ac8a57538da57d", + "lastModified": 1637475807, + "narHash": "sha256-E3nzOvlzZXwyo8Stp5upKsTCDcqUTYAFj4EC060A31c=", + "owner": "nix-community", + "repo": "fenix", + "rev": "960e7fef45692a4fffc6df6d6b613b0399bbdfd5", "type": "github" }, "original": { - "owner": "efishery", - "repo": "dvt", + "owner": "nix-community", + "repo": "fenix", "type": "github" } }, "flake-compat": { - "flake": false, - "locked": { - "lastModified": 1696426674, - "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, - "flake-compat_2": { - "flake": false, - "locked": { - "lastModified": 1641205782, - "narHash": "sha256-4jY7RCWUoZ9cKD8co0/4tFARpWB+57+r1bLLvXNJliY=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "b7547d3eed6f32d06102ead8991ec52ab0a4f1a7", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, - "flake-compat_3": { - "flake": false, - "locked": { - "lastModified": 1641205782, - "narHash": "sha256-4jY7RCWUoZ9cKD8co0/4tFARpWB+57+r1bLLvXNJliY=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "b7547d3eed6f32d06102ead8991ec52ab0a4f1a7", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, - "flake-compat_4": { "flake": false, "locked": { "lastModified": 1673956053, @@ -107,26 +60,11 @@ }, "flake-utils": { "locked": { - "lastModified": 1644229661, - "narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_2": { - "locked": { - "lastModified": 1644229661, - "narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=", + "lastModified": 1637014545, + "narHash": "sha256-26IZAc5yzlD9FlDT54io1oqG/bBoyka+FJk5guaX4x4=", "owner": "numtide", "repo": "flake-utils", - "rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797", + "rev": "bba5dcc8e0b20ab664967ad83d24d64cb64ec4f4", "type": "github" }, "original": { @@ -135,63 +73,40 @@ "type": "github" } }, - "flake-utils_3": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1685518550, - "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "gitignore": { + "home": { "inputs": { "nixpkgs": [ - "precommit", "nixpkgs" ] }, "locked": { - "lastModified": 1660459072, - "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=", - "owner": "hercules-ci", - "repo": "gitignore.nix", - "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73", + "lastModified": 1702195668, + "narHash": "sha256-Lxmjez0nfNBptdqV5GsXKm7Bb7swjGsrxiLxWJu0tL8=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "33110fb3c7fe6a94b98b641866a5eddb64b7c23f", "type": "github" }, "original": { - "owner": "hercules-ci", - "repo": "gitignore.nix", + "owner": "nix-community", + "ref": "release-23.05", + "repo": "home-manager", "type": "github" } }, - "home-manager": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, + "libgit2": { + "flake": false, "locked": { - "lastModified": 1695108154, - "narHash": "sha256-gSg7UTVtls2yO9lKtP0yb66XBHT1Fx5qZSZbGMpSn2c=", - "owner": "nix-community", - "repo": "home-manager", - "rev": "07682fff75d41f18327a871088d20af2710d4744", + "lastModified": 1697646580, + "narHash": "sha256-oX4Z3S9WtJlwvj0uH9HlYcWv+x1hqp8mhXl7HsLu2f0=", + "owner": "libgit2", + "repo": "libgit2", + "rev": "45fd9ed7ae1a9b74b957ef4f337bc3c8b3df01b5", "type": "github" }, "original": { - "owner": "nix-community", - "ref": "release-23.05", - "repo": "home-manager", + "owner": "libgit2", + "repo": "libgit2", "type": "github" } }, @@ -211,215 +126,118 @@ "type": "github" } }, - "neorg": { - "flake": false, + "master": { "locked": { - "lastModified": 1699452256, - "narHash": "sha256-GuC/p47bHnyCLB7DXloV+GgVliOST9vQ9DAme5g4o9w=", - "owner": "nvim-neorg", - "repo": "neorg", - "rev": "55090798a2eed2dd00fc1b2774bc6bf309a3bd0b", + "lastModified": 1707842995, + "narHash": "sha256-NMBnyjeR19RJx9xKqSbzuJi8UIn9/x9+WuR3plsgMNo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "876deff81cd4a4d38da277fbfd7aee722a6a8322", "type": "github" }, "original": { - "owner": "nvim-neorg", - "repo": "neorg", + "owner": "NixOS", + "ref": "master", + "repo": "nixpkgs", "type": "github" } }, - "neorg-overlay": { + "nix": { "inputs": { - "flake-utils": [ - "utils" - ], - "neorg": "neorg", - "neorg-telescope": "neorg-telescope", + "flake-compat": "flake-compat", + "libgit2": "libgit2", "nixpkgs": [ "nixpkgs" ], - "norg": "norg", - "norg-meta": "norg-meta" - }, - "locked": { - "lastModified": 1699452691, - "narHash": "sha256-EW3QL4p72vhvRHeWGLVbGGFHMl1kXG6aICMZgMofhTc=", - "owner": "nvim-neorg", - "repo": "nixpkgs-neorg-overlay", - "rev": "80c9e18487855755a191999b03ba7e5664942807", - "type": "github" + "nixpkgs-regression": "nixpkgs-regression" }, - "original": { - "owner": "nvim-neorg", - "repo": "nixpkgs-neorg-overlay", - "type": "github" - } - }, - "neorg-telescope": { - "flake": false, "locked": { - "lastModified": 1698320305, - "narHash": "sha256-BOiIYZtRoKJP9BDmNf1doDQs09hRIVM2W8qw0sSDU18=", - "owner": "nvim-neorg", - "repo": "neorg-telescope", - "rev": "c3d25cc46145fba82c410245fb5bea66945eb1de", + "lastModified": 1707839381, + "narHash": "sha256-eEuALh/dU/Kx22n1WmF04cxUCLBLnobfshdiI8dKqso=", + "owner": "nixos", + "repo": "nix", + "rev": "4254cdabf26c1e6536625d23ed102615414d0667", "type": "github" }, "original": { - "owner": "nvim-neorg", - "repo": "neorg-telescope", + "owner": "nixos", + "repo": "nix", "type": "github" } }, - "nixpkgs": { - "locked": { - "lastModified": 1644486793, - "narHash": "sha256-EeijR4guVHgVv+JpOX3cQO+1XdrkJfGmiJ9XVsVU530=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "1882c6b7368fd284ad01b0a5b5601ef136321292", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs-master": { - "locked": { - "lastModified": 1699468977, - "narHash": "sha256-NRsaMly5VDGQ6a3+S0GuuVULdB+rwSRrdUeKtsx4TYg=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "2a4751dc3f6917fe7e9a1e3779dd3dc887cb780d", - "type": "github" + "nix-index-database": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] }, - "original": { - "owner": "NixOS", - "ref": "master", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs-stable": { "locked": { - "lastModified": 1699375123, - "narHash": "sha256-ny0+k0LQPVAhntYZo/FMVFxUlejpn4pIQVOo5Vdek/I=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "bceb3bff2ee78424c1073d0b4676858265f926d1", + "lastModified": 1707620986, + "narHash": "sha256-XE0tCSkSVBeJDWhjFwusNInwAhrnp+TloUNUpvnTiLw=", + "owner": "Mic92", + "repo": "nix-index-database", + "rev": "0cb4345704123492e6d1f1068629069413c80de0", "type": "github" }, "original": { - "owner": "NixOS", - "ref": "nixpkgs-23.05-darwin", - "repo": "nixpkgs", + "owner": "Mic92", + "repo": "nix-index-database", "type": "github" } }, - "nixpkgs-stable_2": { - "locked": { - "lastModified": 1685801374, - "narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "c37ca420157f4abc31e26f436c1145f8951ff373", - "type": "github" + "nixpkgs-fmt": { + "inputs": { + "fenix": "fenix", + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ] }, - "original": { - "owner": "NixOS", - "ref": "nixos-23.05", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs-unstable": { "locked": { - "lastModified": 1699343069, - "narHash": "sha256-s7BBhyLA6MI6FuJgs4F/SgpntHBzz40/qV0xLPW6A1Q=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "ec750fd01963ab6b20ee1f0cb488754e8036d89d", + "lastModified": 1705307188, + "narHash": "sha256-2UDso6ALCoqVH0Q0boIYRT9NJtto8CECAc+gUIHi1/o=", + "owner": "nix-community", + "repo": "nixpkgs-fmt", + "rev": "7301bc9f2ba29fe693c04cbcaa12110eb9685c71", "type": "github" }, "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", + "owner": "nix-community", + "repo": "nixpkgs-fmt", "type": "github" } }, - "nixpkgs_2": { + "nixpkgs-lib": { "locked": { - "lastModified": 1644486793, - "narHash": "sha256-EeijR4guVHgVv+JpOX3cQO+1XdrkJfGmiJ9XVsVU530=", + "dir": "lib", + "lastModified": 1706550542, + "narHash": "sha256-UcsnCG6wx++23yeER4Hg18CXWbgNpqNXcHIo5/1Y+hc=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "1882c6b7368fd284ad01b0a5b5601ef136321292", + "rev": "97b17f32362e475016f942bbdfda4a4a72a8a652", "type": "github" }, "original": { + "dir": "lib", "owner": "NixOS", - "ref": "nixpkgs-unstable", + "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" } }, - "nixpkgs_3": { + "nixpkgs-regression": { "locked": { - "lastModified": 1699458350, - "narHash": "sha256-AHoi7cM4SzQTpu4ZMzt+KDoxxka/qjGPvR+0lvaLgf0=", + "lastModified": 1643052045, + "narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "da44563672fb0faca83dc56185472e56d1a21852", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", "type": "github" }, "original": { "owner": "NixOS", - "ref": "release-23.05", "repo": "nixpkgs", - "type": "github" - } - }, - "norg": { - "inputs": { - "flake-compat": "flake-compat_2", - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" - }, - "locked": { - "lastModified": 1672582520, - "narHash": "sha256-kv3UiJUqMSF1qd3r4OCWomVTHTYjwX/EBRWm8mOSdwg=", - "owner": "nvim-neorg", - "repo": "tree-sitter-norg", - "rev": "d7a466e182a532065a559dbfc7a847271d5e9c29", - "type": "github" - }, - "original": { - "owner": "nvim-neorg", - "ref": "dev", - "repo": "tree-sitter-norg", - "type": "github" - } - }, - "norg-meta": { - "inputs": { - "flake-compat": "flake-compat_3", - "flake-utils": "flake-utils_2", - "nixpkgs": "nixpkgs_2" - }, - "locked": { - "lastModified": 1685293302, - "narHash": "sha256-7tCmYem8vpgG+9HM92cbQH1r+h+iRDf7wfrxQGoadO8=", - "owner": "nvim-neorg", - "repo": "tree-sitter-norg-meta", - "rev": "a479d1ca05848d0b51dd25bc9f71a17e0108b240", - "type": "github" - }, - "original": { - "owner": "nvim-neorg", - "repo": "tree-sitter-norg-meta", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", "type": "github" } }, @@ -439,47 +257,42 @@ "type": "github" } }, - "precommit": { + "parts": { "inputs": { - "flake-compat": "flake-compat_4", - "flake-utils": "flake-utils_3", - "gitignore": "gitignore", - "nixpkgs": [ - "nixpkgs" - ], - "nixpkgs-stable": "nixpkgs-stable_2" + "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1699271226, - "narHash": "sha256-8Jt1KW3xTjolD6c6OjJm9USx/jmL+VVmbooADCkdDfU=", - "owner": "cachix", - "repo": "pre-commit-hooks.nix", - "rev": "ea758da1a6dcde6dc36db348ed690d09b9864128", + "lastModified": 1706830856, + "narHash": "sha256-a0NYyp+h9hlb7ddVz4LUn1vT/PLwqfrWYcHMvFB1xYg=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "b253292d9c0a5ead9bc98c4e9a26c6312e27d69f", "type": "github" }, "original": { - "owner": "cachix", - "repo": "pre-commit-hooks.nix", + "owner": "hercules-ci", + "repo": "flake-parts", "type": "github" } }, "root": { "inputs": { "darwin": "darwin", - "dvt": "dvt", - "flake-compat": "flake-compat", - "home-manager": "home-manager", + "home": "home", "luafun": "luafun", - "neorg-overlay": "neorg-overlay", - "nixpkgs": "nixpkgs_3", - "nixpkgs-master": "nixpkgs-master", - "nixpkgs-stable": "nixpkgs-stable", - "nixpkgs-unstable": "nixpkgs-unstable", + "master": "master", + "nix": "nix", + "nix-index-database": "nix-index-database", + "nixpkgs": [ + "master" + ], + "nixpkgs-fmt": "nixpkgs-fmt", "nvim-treesitter": "nvim-treesitter", - "precommit": "precommit", + "parts": "parts", "sops": "sops", + "stable": "stable", "ts-rescript": "ts-rescript", - "utils": "utils_2", + "unstable": "unstable", "vimPlugins_chatgpt-nvim": "vimPlugins_chatgpt-nvim", "vimPlugins_codeium": "vimPlugins_codeium", "vimPlugins_git-conflict-nvim": "vimPlugins_git-conflict-nvim", @@ -488,13 +301,30 @@ "vimPlugins_vim-rescript": "vimPlugins_vim-rescript" } }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1637439871, + "narHash": "sha256-2awQ/obzl7zqYgLwbQL0zT58gN8Xq7n+81GcMiS595I=", + "owner": "rust-analyzer", + "repo": "rust-analyzer", + "rev": "4566414789310acb2617543f4b50beab4bb48e06", + "type": "github" + }, + "original": { + "owner": "rust-analyzer", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + }, "sops": { "inputs": { "nixpkgs": [ "nixpkgs" ], "nixpkgs-stable": [ - "nixpkgs-stable" + "stable" ] }, "locked": { @@ -511,33 +341,19 @@ "type": "github" } }, - "systems": { + "stable": { "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - }, - "systems_2": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "lastModified": 1688392541, + "narHash": "sha256-lHrKvEkCPTUO+7tPfjIcb7Trk6k31rz18vkyqmkeJfY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b", "type": "github" }, "original": { - "owner": "nix-systems", - "repo": "default", + "owner": "NixOS", + "ref": "release-22.11", + "repo": "nixpkgs", "type": "github" } }, @@ -557,36 +373,19 @@ "type": "github" } }, - "utils": { + "unstable": { "locked": { - "lastModified": 1667395993, - "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "utils_2": { - "inputs": { - "systems": "systems_2" - }, - "locked": { - "lastModified": 1694529238, - "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "lastModified": 1707743206, + "narHash": "sha256-AehgH64b28yKobC/DAWYZWkJBxL/vP83vkY+ag2Hhy4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "2d627a2a704708673e56346fcb13d25344b8eaf3", "type": "github" }, "original": { - "owner": "numtide", - "repo": "flake-utils", + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", "type": "github" } }, diff --git a/flake.nix b/flake.nix index 74b4462..b79b415 100644 --- a/flake.nix +++ b/flake.nix @@ -1,42 +1,52 @@ { description = "ri7's nix darwin system"; + outputs = inputs: inputs.parts.lib.mkFlake { inherit inputs; } { + systems = [ + "aarch64-darwin" + "x86_64-linux" + ]; + + imports = [ + ./overlays + ./modules/parts + ./hosts + ./users + ]; + }; + inputs = { - # Package sets - nixpkgs.url = "github:NixOS/nixpkgs/release-23.05"; - nixpkgs-master.url = "github:NixOS/nixpkgs/master"; - nixpkgs-stable.url = "github:NixOS/nixpkgs/nixpkgs-23.05-darwin"; - nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + nix.url = "github:nixos/nix"; + nix.inputs.nixpkgs.follows = "nixpkgs"; + + nix-index-database.url = "github:Mic92/nix-index-database"; + nix-index-database.inputs.nixpkgs.follows = "nixpkgs"; + + # utilities for Flake + parts.url = "github:hercules-ci/flake-parts"; + nixpkgs-fmt.url = "github:nix-community/nixpkgs-fmt"; + nixpkgs-fmt.inputs.nixpkgs.follows = "nixpkgs"; - # Other sources / nix utilities - flake-compat = { url = "github:edolstra/flake-compat"; flake = false; }; - utils.url = "github:numtide/flake-utils"; + ## -- nixpkgs + master.url = "github:NixOS/nixpkgs/master"; + stable.url = "github:NixOS/nixpkgs/release-22.11"; + unstable.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + nixpkgs.follows = "master"; - # Environment/system management + ## -- Platform + + #### ---- MacOS darwin.url = "github:LnL7/nix-darwin"; darwin.inputs.nixpkgs.follows = "nixpkgs"; - # home-manager inputs - home-manager.url = "github:nix-community/home-manager/release-23.05"; - home-manager.inputs.nixpkgs.follows = "nixpkgs"; + #### ---- Home + home.url = "github:nix-community/home-manager/release-23.05"; + home.inputs.nixpkgs.follows = "nixpkgs"; # secret management sops.url = "github:Mic92/sops-nix"; sops.inputs.nixpkgs.follows = "nixpkgs"; - sops.inputs.nixpkgs-stable.follows = "nixpkgs-stable"; - - # utilities - precommit.url = "github:cachix/pre-commit-hooks.nix"; - precommit.inputs.nixpkgs.follows = "nixpkgs"; - - # neovim - neorg-overlay.url = "github:nvim-neorg/nixpkgs-neorg-overlay"; - neorg-overlay.inputs.nixpkgs.follows = "nixpkgs"; - neorg-overlay.inputs.flake-utils.follows = "utils"; - - # dvt - dvt.url = "github:efishery/dvt"; - dvt.inputs.nixpkgs.follows = "nixpkgs"; + sops.inputs.nixpkgs-stable.follows = "stable"; # vimPlugins from flake inputs # prefix "vimPlugins_" @@ -55,358 +65,4 @@ ts-rescript = { url = "github:nkrkv/tree-sitter-rescript"; flake = false; }; luafun = { url = "github:luafun/luafun"; flake = false; }; }; - - outputs = - { self - , darwin - , home-manager - , sops - , utils - , ... - } @inputs: - - let - inherit (darwin.lib) darwinSystem; - inherit (self.lib) attrValues makeOverridable singleton optionalAttrs; - # Overlays --------------------------------------------------------------------------------{{{ - - config = { allowUnfree = true; }; - - overlays = - { - # Overlays Package Sets ---------------------------------------------------------------{{{ - # Overlays to add different versions `nixpkgs` into package set - pkgs-master = _: prev: { - pkgs-master = import inputs.nixpkgs-master { - inherit (prev.stdenv) system; - inherit config; - }; - }; - pkgs-stable = _: prev: { - pkgs-stable = import inputs.nixpkgs-stable { - inherit (prev.stdenv) system; - inherit config; - }; - }; - pkgs-unstable = _: prev: { - pkgs-unstable = import inputs.nixpkgs-unstable { - inherit (prev.stdenv) system; - inherit config; - }; - }; - apple-silicon = _: prev: optionalAttrs (prev.stdenv.system == "aarch64-darwin") { - # Add access to x86 packages system is running Apple Silicon - pkgs-x86 = import inputs.nixpkgs { - system = "x86_64-darwin"; - inherit config; - }; - }; - # ------------------------------------------------------------------------------------}}} - - mac-pkgs = import ./overlays/mac-pkgs; - - # Overlay that adds various additional utility functions to `vimUtils` - vimUtils = import ./overlays/vimUtils.nix; - - treesitter = _final: prev: { - tree-sitter-grammars = prev.tree-sitter-grammars // { - tree-sitter-rescript = - prev.pkgs-unstable.tree-sitter.buildGrammar { - version = inputs.ts-rescript.lastModifiedDate; - language = "rescript"; - generate = true; - src = inputs.ts-rescript; - }; - }; - }; - - # Overlay that add some additional lua library - luajitPackages = _final: prev: { - luajitPackages = prev.luajitPackages // { - luafun = prev.luajitPackages.buildLuarocksPackage { - pname = "fun"; - version = "scm-1"; - - src = inputs.luafun; - - disabled = (prev.luajitPackages.luaOlder "5.1") || (prev.luajitPackages.luaAtLeast "5.4"); - propagatedBuildInputs = [ prev.lua ]; - - meta = { - homepage = "https://luafun.github.io/"; - description = "High-performance functional programming library for Lua"; - license.fullName = "MIT/X11"; - }; - }; - }; - }; - - # Overlay that adds some additional Neovim plugins - vimPlugins = _final: prev: { - vimPlugins = prev.vimPlugins.extend (_: p: { - nvim-treesitter = p.nvim-treesitter.overrideAttrs (_: { - version = inputs.nvim-treesitter.lastModifiedDate; - src = inputs.nvim-treesitter; - }); - } // self.lib.mkFlake2VimPlugin { pkgs = prev; }); - }; - - }; - - # }}} - - # default configurations --------------------------------------------------------------{{{ - # Configuration for `nixpkgs` - defaultNixpkgs = { - inherit config; - overlays = attrValues overlays - ++ singleton (inputs.neorg-overlay.overlays.default) - ++ singleton (inputs.dvt.overlay); - }; - - # Personal configuration shared between `nix-darwin` and plain `home-manager` configs. - homeManagerStateVersion = "23.05"; - - primaryUserInfo = rec { - username = "r17"; - fullName = "Rin"; - email = "hi@rin.rocks"; - nixConfigDirectory = "/Users/${username}/.config/nixpkgs"; - within = { - neovim.enable = true; - gpg.enable = true; - pass.enable = true; - }; - }; - - # Modules shared by most `nix-darwin` personal configurations. - nixDarwinCommonModules = attrValues self.commonModules - ++ attrValues self.darwinModules - ++ [ - # `home-manager` module - home-manager.darwinModules.home-manager - ( - { config, pkgs, ... }: - let - inherit (config.users) primaryUser; - in - { - nixpkgs = defaultNixpkgs; - # Hack to support legacy worklows that use `` etc. - nix.nixPath = { nixpkgs = "${inputs.nixpkgs}"; }; - # `home-manager` config - users.users.${primaryUser.username} = { - home = "/Users/${primaryUser.username}"; - shell = pkgs.fish; - }; - - home-manager.useGlobalPkgs = true; - home-manager.users.${primaryUser.username} = { - imports = attrValues self.homeManagerModules; - home.stateVersion = homeManagerStateVersion; - home.user-info = config.users.primaryUser; - }; - - # Add a registry entry for this flake - nix.registry = { - my.flake = self; - dvt.flake = inputs.dvt; - }; - } - ) - ]; - - # }}} - in - { - - lib = inputs.nixpkgs.lib.extend (_: _: { - mkFlake2VimPlugin = import ./lib/mkFlake2VimPlugin.nix inputs; - }); - - # Modules --------------------------------------------------------------------------------{{{ - # Current Macbook Pro M1 from Ruangguru.com - darwinConfigurations = rec { - # TODO refactor darwin.nix to make common or bootstrap configuration - bootstrap-x86 = makeOverridable darwinSystem { - system = "x86_64-darwin"; - modules = attrValues self.commonModules; - }; - - bootstrap-arm = bootstrap-x86.override { system = "aarch64-darwin"; }; - - RG = bootstrap-arm.override { - modules = nixDarwinCommonModules ++ [ - { - users.primaryUser = primaryUserInfo; - networking.computerName = "RG"; - networking.hostName = "RG"; - networking.knownNetworkServices = [ - "Wi-Fi" - "USB 10/100/1000 LAN" - ]; - } - ]; - }; - - eR17 = RG.override { - modules = nixDarwinCommonModules ++ [ - { - users.primaryUser = primaryUserInfo; - networking.computerName = "eR17"; - networking.hostName = "eR17"; - networking.knownNetworkServices = [ - "Wi-Fi" - "USB 10/100/1000 LAN" - ]; - homebrew.enable = true; - } - - home-manager.darwinModules.home-manager - ({ config, pkgs, ... }: { - home-manager.users.${config.users.primaryUser.username} = { - imports = singleton sops.homeManagerModule; - home.packages = [ pkgs.sops ]; - sops.gnupg.home = "~/.gnupg"; - sops.gnupg.sshKeyPaths = [ ]; - sops.defaultSopsFile = ./secrets/secret.yaml; - # git diff integrations - programs.git.extraConfig.diff.sopsdiffer.textconv = "sops -d"; - }; - }) - ]; - }; - - eR17x = eR17.override { - modules = nixDarwinCommonModules ++ [ - { - users.primaryUser = primaryUserInfo // rec { - username = "er17x"; - nixConfigDirectory = "/Users/${username}/.config/nixpkgs"; - }; - networking.computerName = "eR17x"; - networking.hostName = "eR17x"; - networking.knownNetworkServices = [ - "Wi-Fi" - "USB 10/100/1000 LAN" - ]; - homebrew.enable = true; - } - - home-manager.darwinModules.home-manager - ({ config, pkgs, ... }: { - home-manager.users.${config.users.primaryUser.username} = { - imports = singleton sops.homeManagerModule; - home.packages = [ pkgs.sops ]; - sops.gnupg.home = "~/.gnupg"; - sops.gnupg.sshKeyPaths = [ ]; - sops.defaultSopsFile = ./secrets/secret.yaml; - # git diff integrations - programs.git.extraConfig.diff.sopsdiffer.textconv = "sops -d"; - }; - }) - - ]; - }; - - }; - - homeConfigurations.r17 = - let - pkgs = import inputs.nixpkgs (defaultNixpkgs // { system = "aarch64-darwin"; }); - in - inputs.home-manager.lib.homeManagerConfiguration { - inherit pkgs; - modules = attrValues self.homeManagerModules - ++ singleton ({ config, ... }: { - home.username = config.home.user-info.username; - home.homeDirectory = "/${if pkgs.stdenv.isDarwin then "Users" else "home"}/${config.home.username}"; - home.stateVersion = homeManagerStateVersion; - home.user-info = primaryUserInfo // { - nixConfigDirectory = "${config.home.homeDirectory}/.config/nixpkgs"; - }; - }); - }; - - # `home-manager` modules - homeManagerModules = { - r17-alacritty = import ./home/alacritty.nix; - r17-activation = import ./home/activation.nix; - r17-packages = import ./home/packages.nix; - r17-shell = import ./home/shells.nix; - r17-git = import ./home/git.nix; - r17-tmux = import ./home/tmux.nix; - r17-neovim = import ./home/neovim.nix; - gpg = import ./home/gpg.nix; - pass = import ./home/pass.nix; - - home-user-info = { lib, ... }: { - options.home.user-info = - (self.commonModules.users-primaryUser { inherit lib; }).options.users.primaryUser; - }; - }; - - commonModules = { - system = import ./system/system.nix; - system-shells = import ./system/shells.nix; - users-primaryUser = import ./modules/user.nix; - programs-nix-index = import ./system/nix-index.nix; - }; - - # fixes. - darwinModules = { - system-darwin = import ./system/darwin/system.nix; - system-darwin-packages = import ./system/darwin/packages.nix; - # system-darwin-security-pam = import ./system/darwin/security.nix; - system-darwin-gpg = import ./system/darwin/gpg.nix; - system-darwin-window-manager = import ./system/darwin/mouseless.nix; - system-darwin-homebrew = import ./system/darwin/homebrew.nix; - system-darwin-network = import ./system/darwin/network.nix; - }; - - # }}} - - } // utils.lib.eachDefaultSystem (system: rec { - - legacyPackages = import inputs.nixpkgs (defaultNixpkgs // { inherit system; }); - - # Checks ----------------------------------------------------------------------{{{ - # e.g., run `nix flake check` in $HOME/.config/nixpkgs. - - checks = { - pre-commit-check = inputs.precommit.lib.${system}.run { - src = ./.; - # you can enable more hooks here {https://github.com/cachix/pre-commit-hooks.nix/blob/a4548c09eac4afb592ab2614f4a150120b29584c/modules/hooks.nix} - hooks = { - actionlint.enable = true; - shellcheck.enable = true; - stylua.enable = true; - # TODO https://github.com/cachix/pre-commit-hooks.nix/issues/196 - # make override and pass configuration - luacheck.enable = false; - - # .nix related - deadnix.enable = true; - nixpkgs-fmt.enable = true; - }; - }; - }; - - # }}} - - # Development shells ----------------------------------------------------------------------{{{ - # Shell environments for development - # With `nix.registry.my.flake = inputs.self`, development shells can be created by running, - # e.g., `nix develop my#node`. - - devShells = import ./devShells.nix { - pkgs = self.legacyPackages.${system}; - precommit = checks.pre-commit-check; - }; - - # }}} - - }); } - -# vim: foldmethod=marker diff --git a/home/shells.nix b/home/shells.nix index 40be46b..e07203c 100644 --- a/home/shells.nix +++ b/home/shells.nix @@ -105,6 +105,10 @@ let in { home = with pkgs;{ + sessionVariables = { + OPENAI_API_KEY = "$(cat ${config.sops.secrets.openai_api_key.path})"; + }; + inherit shellAliases; sessionPath = [ "$HOME/.yarn/bin" diff --git a/hosts/default.nix b/hosts/default.nix new file mode 100644 index 0000000..8fa12c4 --- /dev/null +++ b/hosts/default.nix @@ -0,0 +1,40 @@ +{ ... }: + +let + sharedModules = [ + ../shared/darwin/gpg.nix + ../shared/darwin/homebrew.nix + ../shared/darwin/network.nix + ../shared/darwin/packages.nix + ../shared/darwin/system.nix + ]; +in + +{ + # nix-darwin configurations + parts.darwinConfigurations = { + # Apple M1 + eR17x = { + system = "aarch64-darwin"; + stateVersion = 4; + modules = sharedModules; + }; + }; + + # NixOS configurations + # parts.nixosConfigurations = { + # linuxBased = { + # system = "x86_64-linux"; + # stateVersion = "23.05"; + + # modules = []; + # }; + # wsl2 = { + # system = "x86_64-linux"; + # stateVersion = "22.05"; # only change this if you know what you are doing. + # wsl = true; + + # modules = [ ]; + # }; + #}; +} diff --git a/modules/parts/darwin.nix b/modules/parts/darwin.nix new file mode 100644 index 0000000..dffed3d --- /dev/null +++ b/modules/parts/darwin.nix @@ -0,0 +1,63 @@ +{ config, lib, inputs, withSystem, ... }: + +let + inherit lib; + inherit (lib) types; + + cfg = config.parts.darwinConfigurations; + configurations = builtins.mapAttrs (_: value: value._darwin) cfg; + + darwinOpts = { config, name, ... }: { + options = { + system = lib.mkOption { + type = types.enum [ "aarch64-darwin" "x86_64-darwin" ]; + description = "System architecture for the configuration."; + }; + + stateVersion = lib.mkOption { + type = types.int; + description = "nix-darwin state version, changing this value DOES NOT update your system."; + }; + + modules = lib.mkOption { + type = types.listOf types.unspecified; + description = "List of nix-darwin modules to include in the configuration."; + }; + + _darwin = lib.mkOption { + type = types.unspecified; + readOnly = true; + description = "Composed nix-darwin configuration."; + }; + }; + + config._darwin = withSystem config.system (ctx: + inputs.darwin.lib.darwinSystem { + inherit inputs; + inherit (ctx) system; + + modules = config.modules ++ [ + # Composed home-manager configuration. + inputs.home.darwinModules.home-manager + + ({ pkgs, ... }: { + inherit (ctx) nix; + nixpkgs = removeAttrs ctx.nixpkgs [ "hostPlatform" ]; + _module.args = ctx.extraModuleArgs; + networking.hostName = name; + networking.computerName = name; + system.stateVersion = config.stateVersion; + environment.systemPackages = ctx.basePackagesFor pkgs; + }) + ]; + } + ); + }; +in +{ + options.parts.darwinConfigurations = lib.mkOption { + type = types.attrsOf (types.submodule darwinOpts); + }; + + config.flake.darwinConfigurations = configurations; +} diff --git a/modules/parts/default.nix b/modules/parts/default.nix new file mode 100644 index 0000000..e862262 --- /dev/null +++ b/modules/parts/default.nix @@ -0,0 +1,76 @@ +{ self, inputs, ... }: + +{ + imports = [ + ./home.nix + ./darwin.nix + ]; + + perSystem = { lib, pkgs, system, inputs', ... }: { + formatter = inputs.nixpkgs-fmt.defaultPackage.${system}; + + _module.args = rec { + # the nix package manager configurations and settings. + nix = import ./nix.nix { + inherit lib inputs inputs'; + inherit (pkgs) stdenv; + }; + + # nixpkgs (channel) configuration (not the flake input) + nixpkgs = { + config = lib.mkForce { + allowBroken = true; + allowUnfree = true; + tarball-ttl = 0; + + # Experimental options, disable if you don't know what you are doing! + contentAddressedByDefault = false; + }; + + hostPlatform = system; + + overlays = lib.mkForce [ + self.overlays.default + ]; + }; + + # Extra arguments passed to the module system for nix-darwin, NixOS, and home-manager + extraModuleArgs = { + inherit inputs' system; + inputs = lib.mkForce inputs; + + /* + One can access these nixpkgs branches like so: + + `branches.stable.mpd' + `branches.master.linuxPackages_xanmod' + */ + branches = + let + pkgsFrom = branch: system: import branch { + inherit system; + inherit (nixpkgs) config overlays; + }; + in + { + master = pkgsFrom inputs.master system; + unstable = pkgsFrom inputs.unstable system; + stable = pkgsFrom inputs.stable system; + }; + }; + + # NixOS and nix-darwin base environment.systemPackages + basePackagesFor = pkgs: builtins.attrValues { + inherit (pkgs) + vim + curl + fd + man-pages-posix + wget + git; + + home-manager = inputs'.home.packages.home-manager.override { path = "${inputs.home}"; }; + }; + }; + }; +} diff --git a/modules/parts/home.nix b/modules/parts/home.nix new file mode 100644 index 0000000..6325d9d --- /dev/null +++ b/modules/parts/home.nix @@ -0,0 +1,78 @@ +{ config, lib, inputs, withSystem, ... }: + +let + inherit lib; + inherit (lib) types; + + cfg = config.parts.homeConfigurations; + configurations = builtins.mapAttrs (_: value: value._home) cfg; + + homeOpts = opts@{ config, lib, name, ... }: { + options = { + system = lib.mkOption { + type = types.enum [ + "aarch64-darwin" + "aarch64-linux" + "x86_64-darwin" + "x86_64-linux" + ]; + + description = "System architecture for the configuration."; + }; + + stateVersion = lib.mkOption { + type = types.str; + description = "home-manager state version, changing this value DOES NOT update your config."; + }; + + modules = lib.mkOption { + type = types.listOf types.unspecified; + description = "List of home-manager modules to include in the configuration."; + }; + + _home = lib.mkOption { + type = types.unspecified; + readOnly = true; + description = "Composed home-manager configuration."; + }; + }; + + config._home = withSystem config.system (ctx: + inputs.home.lib.homeManagerConfiguration { + # Default nixpkgs for home.nix + pkgs = inputs.nixpkgs.legacyPackages.${ctx.system}; + + modules = config.modules ++ [ + inputs.nix-index-database.hmModules.nix-index + + ({ config, lib, pkgs, ... }: { + _module.args = ctx.extraModuleArgs; + nixpkgs = removeAttrs ctx.nixpkgs [ "hostPlatform" ]; + + home = { + username = builtins.elemAt (lib.strings.split "@" name) 0; + inherit (opts.config) stateVersion; + + packages = builtins.attrValues { + inherit (pkgs) + hello; + }; + + homeDirectory = lib.mkMerge [ + (lib.mkIf pkgs.stdenv.isDarwin "/Users/${config.home.username}") + (lib.mkIf pkgs.stdenv.isLinux "/home/${config.home.username}") + ]; + }; + }) + ]; + } + ); + }; +in +{ + options.parts.homeConfigurations = lib.mkOption { + type = types.attrsOf (types.submodule homeOpts); + }; + + config.flake.homeConfigurations = configurations; +} diff --git a/modules/parts/nix.nix b/modules/parts/nix.nix new file mode 100644 index 0000000..942f268 --- /dev/null +++ b/modules/parts/nix.nix @@ -0,0 +1,61 @@ +{ lib, stdenv, inputs, inputs' }: + +{ + configureBuildUsers = true; + + nixPath = [ "nixpkgs=${inputs.nixpkgs}" ]; + + registry = { + system.flake = inputs.self; + default.flake = inputs.nixpkgs; + home-manager.flake = inputs.home; + }; + + settings = { + max-jobs = "auto"; + auto-optimise-store = true; + accept-flake-config = true; + + experimental-features = [ + "auto-allocate-uids" + "ca-derivations" + "flakes" + "nix-command" + ]; + + trusted-users = [ "r17" "nixos" "root" ]; + + trusted-substituters = [ + "https://cache.komunix.org" + "https://nix-community.cachix.org" + "https://r17.cachix.org/" + "https://efishery.cachix.org" + ]; + + trusted-public-keys = [ + "efishery.cachix.org-1:ix7pi358GsGkH7oBTmKGkVj42yBcjxRPi6IQ9AbRc0o=" + "r17.cachix.org-1:vz0nG6BCbdgTPn7SEiOwe/3QwvjH1sb/VV9WLcBtkAY=" + "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + ]; + } // (lib.optionalAttrs (stdenv.isDarwin && stdenv.isAarch64) { + extra-platforms = "x86_64-darwin aarch64-darwin"; + }); + + + # enable garbage-collection on weekly and delete-older-than 30 day + gc = { + automatic = true; + options = "--delete-older-than 30d"; + }; + + # this is configuration for /etc/nix/nix.conf + # so it will generated /etc/nix/nix.conf + extraOptions = '' + keep-outputs = true + keep-derivations = true + auto-allocate-uids = false + builders-use-substitutes = true + http-connections = 0 + ''; +} diff --git a/overlays/default.nix b/overlays/default.nix new file mode 100644 index 0000000..20e6a2b --- /dev/null +++ b/overlays/default.nix @@ -0,0 +1,5 @@ +_: + +{ + flake.overlays.default = final: prev: { }; +} diff --git a/system/darwin/gpg.nix b/shared/darwin/gpg.nix similarity index 100% rename from system/darwin/gpg.nix rename to shared/darwin/gpg.nix diff --git a/system/darwin/homebrew.nix b/shared/darwin/homebrew.nix similarity index 100% rename from system/darwin/homebrew.nix rename to shared/darwin/homebrew.nix diff --git a/system/darwin/mouseless.nix b/shared/darwin/mouseless.nix similarity index 100% rename from system/darwin/mouseless.nix rename to shared/darwin/mouseless.nix diff --git a/system/darwin/network.nix b/shared/darwin/network.nix similarity index 100% rename from system/darwin/network.nix rename to shared/darwin/network.nix diff --git a/system/darwin/packages.nix b/shared/darwin/packages.nix similarity index 100% rename from system/darwin/packages.nix rename to shared/darwin/packages.nix diff --git a/system/darwin/security.nix b/shared/darwin/security.nix similarity index 100% rename from system/darwin/security.nix rename to shared/darwin/security.nix diff --git a/system/darwin/system.nix b/shared/darwin/system.nix similarity index 100% rename from system/darwin/system.nix rename to shared/darwin/system.nix diff --git a/system/nix-index.nix b/shared/nix-index.nix similarity index 100% rename from system/nix-index.nix rename to shared/nix-index.nix diff --git a/system/shells.nix b/shared/shells.nix similarity index 100% rename from system/shells.nix rename to shared/shells.nix diff --git a/system/system.nix b/shared/system.nix similarity index 100% rename from system/system.nix rename to shared/system.nix diff --git a/users/default.nix b/users/default.nix new file mode 100644 index 0000000..c2a7c80 --- /dev/null +++ b/users/default.nix @@ -0,0 +1,10 @@ +_: + +{ + parts.homeConfigurations = { + "r17@eR17x" = { + system = "aarch64-darwin"; + stateVersion = "23.05"; + }; + }; +}