From aad8168cd650d740574205a36998c3c98818e36d Mon Sep 17 00:00:00 2001 From: Rafiyq Widianto Date: Thu, 17 Sep 2020 15:00:26 +0000 Subject: [PATCH] Add new flake.nix file --- flake.nix | 73 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 50 insertions(+), 23 deletions(-) diff --git a/flake.nix b/flake.nix index d688d92..0d376cf 100644 --- a/flake.nix +++ b/flake.nix @@ -1,34 +1,61 @@ { + description = "NixOS configuration"; + inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-20.03"; unstable.url = "github:nixos/nixpkgs/nixos-unstable"; - home.url = "github:rycee/home-manager/bqv-flakes"; + home-manager.url = "github:rycee/home-manager"; emacs.url = "github:nix-community/emacs-overlay"; hardware.url = "github:NixOS/nixos-hardware"; }; - outputs = { self, nix, ... }@inputs: { - nixosConfigurations.nixos = inputs.nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - { - nixpkgs.overlays = [ inputs.emacs.overlay ]; - system.configurationRevision = - if self ? rev - then self.rev - else throw "Refusing to build from a dirty Git tree!"; - } - - inputs.hardware.nixosModules.lenovo-thinkpad-x220 - (import ./hosts/thinkpad-x220) - - inputs.home.nixosModules.home-manager - (import ./modules/home.nix) - - inputs.nixpkgs.nixosModules.notDetected - ]; - specialArgs = { inherit inputs; }; + outputs = inputs: { + nixosConfigurations = { + hostname = let + system = "x86_64-linux"; + pkgs = inputs.nixpkgs.legacyPackages.${system}; + inherit (inputs.nixpkgs) lib; + + # Things in this set are passed to modules and accessible + # in the top-level arguments (e.g. `{ pkgs, lib, inputs, ... }:`). + specialArgs = { + inherit inputs; + }; + + hm-nixos-as-super = { config, ... }: { + # Submodules have merge semantics, making it possible to amend + # the `home-manager.users` submodule for additional functionality. + options.home-manager.users = lib.mkOption { + type = lib.types.attrsOf (lib.types.submoduleWith { + modules = [ ]; + # Makes specialArgs available to Home Manager modules as well. + specialArgs = specialArgs // { + # Allow accessing the parent NixOS configuration. + super = config; + }; + }); + }; + }; + + modules = [ + { + nixpkgs.overlays = [ inputs.emacs.overlay ]; + system.configurationRevision = + if self ? rev + then self.rev + else throw "Refusing to build from a dirty Git tree!"; + } + + inputs.hardware.nixosModules.lenovo-thinkpad-x220 + (import ./hosts/thinkpad-x220) + + inputs.home.nixosModules.home-manager + (import ./modules/home.nix) + + inputs.nixpkgs.nixosModules.notDetected + hm-nixos-as-super + ]; + in lib.nixosSystem { inherit system modules specialArgs; }; }; - nixos = inputs.self.nixosConfigurations.nixos.config.system.build.toplevel; }; }