From dc1bfc8d8317b2ca51d983b94764e9633cbd88f5 Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy Date: Tue, 30 Aug 2022 00:17:21 +0300 Subject: [PATCH] nix: add flake to build home --- flake.lock | 37 +++++++++++++++++++++++++++++++++++++ flake.nix | 32 ++++++++++++++++++++++---------- outputs/home.nix | 16 ++++++++++++++++ outputs/system.nix | 11 +++++++++++ 4 files changed, 86 insertions(+), 10 deletions(-) create mode 100644 outputs/home.nix create mode 100644 outputs/system.nix diff --git a/flake.lock b/flake.lock index 8645efa..26a9ef1 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,26 @@ { "nodes": { + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "utils": "utils" + }, + "locked": { + "lastModified": 1661573386, + "narHash": "sha256-pBEg8iY00Af/SAtU2dlmOAv+2x7kScaGlFRDjNoVJO8=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "d89bdff445eadff03fe414e9c30486bc8166b72b", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1661628722, @@ -18,8 +39,24 @@ }, "root": { "inputs": { + "home-manager": "home-manager", "nixpkgs": "nixpkgs" } + }, + "utils": { + "locked": { + "lastModified": 1653893745, + "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 0ebaf1c..e46d6aa 100644 --- a/flake.nix +++ b/flake.nix @@ -1,16 +1,28 @@ { inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - }; + nixpkgs.url = github:NixOS/nixpkgs/nixos-unstable; - - outputs = { self, nixpkgs }: { - nixosConfigurations.systemHome = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - ./system/configuration.nix - ./system/machine/home - ]; + home-manager = { + url = github:nix-community/home-manager; + inputs.nixpkgs.follows = "nixpkgs"; }; }; + + outputs = inputs @ { self, nixpkgs, ... }: + let + system = "x86_64-linux"; + in + { + homeConfigurations = import ./outputs/home.nix { + inherit inputs system; + }; + + nixosConfigurations = import ./outputs/system.nix { + inherit nixpkgs system; + }; + + devShell.${system} = import ./shell.nix { + pkgs = import nixpkgs { inherit system; }; + }; + }; } diff --git a/outputs/home.nix b/outputs/home.nix new file mode 100644 index 0000000..6dea9b5 --- /dev/null +++ b/outputs/home.nix @@ -0,0 +1,16 @@ +{ inputs, system }: + +with inputs; + +let + pkgs = import nixpkgs { inherit system; }; +in +{ + homeMe = home-manager.lib.homeManagerConfiguration { + inherit pkgs; + + modules = [ + ../home/home.nix + ]; + }; +} diff --git a/outputs/system.nix b/outputs/system.nix new file mode 100644 index 0000000..031d4ab --- /dev/null +++ b/outputs/system.nix @@ -0,0 +1,11 @@ +{ nixpkgs, system }: + +{ + systemHome = nixpkgs.lib.nixosSystem { + inherit system; + modules = [ + ../system/configuration.nix + ../system/machine/home + ]; + }; +}