legacy: ensure config exists

This commit is contained in:
Timothy DeHerrera 2020-01-01 17:16:38 -07:00
parent f69c5a59f1
commit 063d05c680
No known key found for this signature in database
GPG Key ID: 8985725DB5B0C122

View File

@ -3,16 +3,21 @@
# flake support (e.g `nixos-option`), can work as expected. # flake support (e.g `nixos-option`), can work as expected.
{ lib, ... }: { lib, ... }:
let let
host = lib.fileContents /etc/hostname; hostname = lib.fileContents /etc/hostname;
host = "/etc/nixos/hosts/${hostname}.nix";
config =
if (builtins.pathExists host)
then [ host ]
else [ /etc/nixos/hosts/NixOS.nix ];
in in
{ {
imports = builtins.attrValues (import ./modules) ++ [ imports = builtins.attrValues (import ./modules) ++ [
"${builtins.fetchTarball https://github.com/rycee/home-manager/archive/master.tar.gz}/nixos" "${builtins.fetchTarball https://github.com/rycee/home-manager/archive/master.tar.gz}/nixos"
/etc/nixos/profiles/core.nix /etc/nixos/profiles/core.nix
"/etc/nixos/hosts/${host}.nix" ] ++ config;
];
networking.hostName = host;
networking.hostName = hostname;
nix.nixPath = [ nix.nixPath = [
"nixpkgs=${<nixpkgs>}" "nixpkgs=${<nixpkgs>}"
"nixos-config=/etc/nixos/configuration.nix" "nixos-config=/etc/nixos/configuration.nix"