Use Flakes

This commit is contained in:
Paul-Henri Froidmont 2021-07-02 01:47:30 +02:00
parent 6be5927c61
commit bf7f910f23
6 changed files with 119 additions and 5 deletions

18
README.adoc Normal file
View file

@ -0,0 +1,18 @@
== Build a config and switch to it
[source,bash]
----
sudo nixos-rebuild switch --flake .#thehostname
----
If `#thehostname` is not provided, it defaults to the current hostname
== Try to build a configuration
[source,bash]
----
nix build .#nixosConfigurations.thehostname.config.system.build.toplevel
----
== Update lock file to the latest inputs
[source,bash]
----
nix flake update
----

View file

@ -1,3 +0,0 @@
#!/usr/bin/env bash
sudo cp -r configs hosts /etc/nixos/

59
flake.lock generated Normal file
View file

@ -0,0 +1,59 @@
{
"nodes": {
"home-manager": {
"inputs": {
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1625162737,
"narHash": "sha256-IzKTw2u/EKVr6TCQYylSAcOnrVRpir3wG3MUHj2LsTc=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "7df6656b113ce0d39c8b7d30915cafe046e1d64e",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1624922035,
"narHash": "sha256-OiIxJQuMRkICxaUwY3xMBbrPPu20de/n7tVYnWzLvS4=",
"path": "/nix/store/jc7qnirghr97cvwv84nyxi7iqil0jj8a-source",
"rev": "3a8d7958a610cd3fec3a6f424480f91a1b259185",
"type": "path"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1624922035,
"narHash": "sha256-OiIxJQuMRkICxaUwY3xMBbrPPu20de/n7tVYnWzLvS4=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "3a8d7958a610cd3fec3a6f424480f91a1b259185",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"home-manager": "home-manager",
"nixpkgs": "nixpkgs_2"
}
}
},
"root": "root",
"version": 7
}

42
flake.nix Normal file
View file

@ -0,0 +1,42 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager.url = "github:nix-community/home-manager";
};
outputs = { self, home-manager, nixpkgs }: {
nixosConfigurations.nixos-desktop = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules =
[
home-manager.nixosModules.home-manager
{
imports = [
./hosts/nixos-desktop/configuration.nix
];
system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev;
nix.registry.nixpkgs.flake = nixpkgs;
}
];
};
nixosConfigurations.froidmpa-laptop = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules =
[
home-manager.nixosModules.home-manager
{
imports = [
./hosts/froidmpa-laptop/configuration.nix
];
system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev;
nix.registry.nixpkgs.flake = nixpkgs;
}
];
};
};
}

View file

@ -1,7 +1,6 @@
{ config, lib, pkgs, ... }:
{
imports = [
<home-manager/nixos>
./hardware-configuration.nix
../../configs/system.nix
../../configs/network.nix

View file

@ -1,7 +1,6 @@
{ config, lib, pkgs, ... }:
{
imports = [
<home-manager/nixos>
./hardware-configuration.nix
../../configs/system.nix
../../configs/network.nix