From 891b5487b7dba00c85de0ef79bbc29ffeb936005 Mon Sep 17 00:00:00 2001 From: Ruixi-rebirth Date: Wed, 1 May 2024 12:02:13 +0800 Subject: [PATCH] docs/examples: add flake-parts (#488) --- nixd/docs/editors/nvim-lsp.nix | 3 + .../examples/NixOS_Home-Manager/flake.lock | 49 ++++++++++++-- .../examples/NixOS_Home-Manager/flake.nix | 65 +++++++++++-------- 3 files changed, 83 insertions(+), 34 deletions(-) diff --git a/nixd/docs/editors/nvim-lsp.nix b/nixd/docs/editors/nvim-lsp.nix index 933c671b6..2dac06c33 100644 --- a/nixd/docs/editors/nvim-lsp.nix +++ b/nixd/docs/editors/nvim-lsp.nix @@ -377,6 +377,9 @@ let home_manager = { expr = '(builtins.getFlake "/tmp/NixOS_Home-Manager").homeConfigurations."user@hostname".options', }, + flake_parts = { + expr = 'let flake = builtins.getFlake ("/tmp/NixOS_Home-Manager"); in flake.debug.options // flake.currentSystem.options', + }, }, }, }, diff --git a/nixd/docs/examples/NixOS_Home-Manager/flake.lock b/nixd/docs/examples/NixOS_Home-Manager/flake.lock index 837818ca9..1da153aa0 100644 --- a/nixd/docs/examples/NixOS_Home-Manager/flake.lock +++ b/nixd/docs/examples/NixOS_Home-Manager/flake.lock @@ -1,5 +1,23 @@ { "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1712014858, + "narHash": "sha256-sB4SWl2lX95bExY2gMFG5HIzvva5AVMJd4Igm+GpZNw=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "9126214d0a59633752a136528f5f3b9aa8565b7d", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -7,11 +25,11 @@ ] }, "locked": { - "lastModified": 1713818326, - "narHash": "sha256-aw3xbVPJauLk/bbrlakIYxKpeuMWzA2feGrkIpIuXd8=", + "lastModified": 1714515075, + "narHash": "sha256-azMK7aWH0eUc3IqU4Fg5rwZdB9WZBvimOGG3piqvtsY=", "owner": "nix-community", "repo": "home-manager", - "rev": "67de98ae6eed5ad6f91b1142356d71a87ba97f21", + "rev": "6d3b6dc9222c12b951169becdf4b0592ee9576ef", "type": "github" }, "original": { @@ -22,14 +40,32 @@ }, "nixpkgs": { "locked": { - "lastModified": 1713714899, - "narHash": "sha256-+z/XjO3QJs5rLE5UOf015gdVauVRQd2vZtsFkaXBq2Y=", + "lastModified": 1714253743, + "narHash": "sha256-mdTQw2XlariysyScCv2tTE45QSU9v/ezLcHJ22f0Nxc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "58a1abdbae3217ca6b702f03d3b35125d88a2994", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "dir": "lib", + "lastModified": 1711703276, + "narHash": "sha256-iMUFArF0WCatKK6RzfUJknjem0H9m4KgorO/p3Dopkk=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "6143fc5eeb9c4f00163267708e26191d1e918932", + "rev": "d8fe5e6c92d0d190646fb9f1056741a229980089", "type": "github" }, "original": { + "dir": "lib", "owner": "NixOS", "ref": "nixos-unstable", "repo": "nixpkgs", @@ -38,6 +74,7 @@ }, "root": { "inputs": { + "flake-parts": "flake-parts", "home-manager": "home-manager", "nixpkgs": "nixpkgs" } diff --git a/nixd/docs/examples/NixOS_Home-Manager/flake.nix b/nixd/docs/examples/NixOS_Home-Manager/flake.nix index 216472e88..dbd3eae98 100644 --- a/nixd/docs/examples/NixOS_Home-Manager/flake.nix +++ b/nixd/docs/examples/NixOS_Home-Manager/flake.nix @@ -1,5 +1,5 @@ { - description = "A simple flake for NixOS and Home Manager"; + description = "A simple flake for NixOS and Home Manager using flake-parts"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; @@ -7,37 +7,46 @@ url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; }; + flake-parts.url = "github:hercules-ci/flake-parts"; }; - outputs = { self, nixpkgs, home-manager, ... }: - { - nixosConfigurations = { - hostname = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - ({ pkgs, ... }: { - networking.hostName = "hostname"; - environment.systemPackages = with pkgs; [ - nixd - ]; - }) - ]; + outputs = inputs@{ self, flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + debug = true; + + systems = [ "x86_64-linux" ]; + + perSystem = { config, ... }: { }; + + flake = { + nixosConfigurations = { + hostname = inputs.nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + ({ pkgs, ... }: { + networking.hostName = "hostname"; + environment.systemPackages = with pkgs; [ + nixd + ]; + }) + ]; + }; }; - }; - homeConfigurations = { - "user@hostname" = home-manager.lib.homeManagerConfiguration { - pkgs = nixpkgs.legacyPackages.x86_64-linux; - modules = [ - { - home.stateVersion = "24.05"; - home.username = "user"; - home.homeDirectory = "/home/user"; - } - ({ pkgs, ... }: { - wayland.windowManager.hyprland.enable = true; - }) - ]; + homeConfigurations = { + "user@hostname" = inputs.home-manager.lib.homeManagerConfiguration { + pkgs = inputs.nixpkgs.legacyPackages.x86_64-linux; + modules = [ + { + home.stateVersion = "24.05"; + home.username = "user"; + home.homeDirectory = "/home/user"; + } + ({ pkgs, ... }: { + wayland.windowManager.hyprland.enable = true; + }) + ]; + }; }; }; };