From 6b7a19160111b9899b209a187de952acf168a352 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Fri, 22 Sep 2023 19:16:54 +0100 Subject: [PATCH] nixos/nix: init, based on nixos/meta and nixos/dev/cross-compiling --- hosts/miku-nixos/default.nix | 1 + hosts/sankyuu-nixos/default.nix | 1 + nixos/dev/default.nix | 1 - nixos/meta.nix | 30 ---------------------- nixos/minimal.nix | 4 +-- nixos/{dev => nix}/cross-compiling.nix | 9 +++---- nixos/nix/default.nix | 35 ++++++++++++++++++++++++++ 7 files changed, 43 insertions(+), 38 deletions(-) delete mode 100644 nixos/meta.nix rename nixos/{dev => nix}/cross-compiling.nix (88%) create mode 100644 nixos/nix/default.nix diff --git a/hosts/miku-nixos/default.nix b/hosts/miku-nixos/default.nix index 8b381890..4ffdcc6b 100644 --- a/hosts/miku-nixos/default.nix +++ b/hosts/miku-nixos/default.nix @@ -18,6 +18,7 @@ in desktop.audio.lowLatency.enable = true; dev.enable = true; games.enable = true; + nix.cross-compiling.enable = true; server = { plex.enable = true; rtorrent.enable = true; diff --git a/hosts/sankyuu-nixos/default.nix b/hosts/sankyuu-nixos/default.nix index c432ece3..e00a0a07 100644 --- a/hosts/sankyuu-nixos/default.nix +++ b/hosts/sankyuu-nixos/default.nix @@ -47,6 +47,7 @@ in nixos = { dev.enable = true; + nix.cross-compiling.enable = true; desktop = { audio.lowLatency = { enable = true; diff --git a/nixos/dev/default.nix b/nixos/dev/default.nix index 03eae41c..8a793502 100644 --- a/nixos/dev/default.nix +++ b/nixos/dev/default.nix @@ -4,7 +4,6 @@ let in { imports = [ - ./cross-compiling.nix ./virtualisation.nix ]; diff --git a/nixos/meta.nix b/nixos/meta.nix deleted file mode 100644 index b569ac1f..00000000 --- a/nixos/meta.nix +++ /dev/null @@ -1,30 +0,0 @@ -{ lib, pkgs, flake, ... }: - -{ - imports = [ - ../cachix.nix - ../overlays - ]; - - # Add some Nix related packages - environment.systemPackages = with pkgs; [ - nixos-cleanup - nom-rebuild - ]; - - # This value determines the NixOS release with which your system is to be - # compatible, in order to avoid breaking some software such as database - # servers. You should change this only after NixOS release notes say you - # should. - system.stateVersion = lib.mkDefault "23.11"; # Did you read the comment? - - nix = import ../shared/nix.nix { inherit pkgs flake; }; - - # Enable unfree packages - nixpkgs.config.allowUnfree = true; - - # Change build dir to /var/tmp - systemd.services.nix-daemon = { - environment.TMPDIR = "/var/tmp"; - }; -} diff --git a/nixos/minimal.nix b/nixos/minimal.nix index 15b1454d..79c73f27 100644 --- a/nixos/minimal.nix +++ b/nixos/minimal.nix @@ -2,8 +2,8 @@ { imports = [ - ./meta.nix - ./system ../modules + ./nix + ./system ]; } diff --git a/nixos/dev/cross-compiling.nix b/nixos/nix/cross-compiling.nix similarity index 88% rename from nixos/dev/cross-compiling.nix rename to nixos/nix/cross-compiling.nix index fd300c08..61fdd3b6 100644 --- a/nixos/dev/cross-compiling.nix +++ b/nixos/nix/cross-compiling.nix @@ -1,19 +1,18 @@ { config, lib, ... }: let - cfg = config.nixos.dev.cross-compiling; + cfg = config.nixos.nix.cross-compiling; in { - options.nixos.dev.cross-compiling = { - enable = lib.mkEnableOption "cross-compiling config for nixpkgs" // { - default = config.nixos.dev.enable; - }; + options.nixos.nix.cross-compiling = { + enable = lib.mkEnableOption "cross-compiling config for nixpkgs"; emulatedSystems = lib.mkOption { description = "List of systems to emulate via QEMU"; type = lib.types.listOf lib.types.str; default = [ "aarch64-linux" ]; }; }; + config = lib.mkIf cfg.enable { # Allow compilation of packages ARM/ARM64 architectures via QEMU # e.g. nix-build -A --argstr system aarch64-linux diff --git a/nixos/nix/default.nix b/nixos/nix/default.nix new file mode 100644 index 00000000..42af8354 --- /dev/null +++ b/nixos/nix/default.nix @@ -0,0 +1,35 @@ +{ config, lib, pkgs, flake, ... }: + +{ + imports = [ + ../../cachix.nix + ../../overlays + ./cross-compiling.nix + ]; + + options.nixos.nix.enable = lib.mkDefaultOption "nix/nixpkgs config"; + + config = lib.mkIf config.nixos.nix.enable { + # Add some Nix related packages + environment.systemPackages = with pkgs; [ + nixos-cleanup + nom-rebuild + ]; + + nix = import ../../shared/nix.nix { inherit pkgs flake; }; + + # Enable unfree packages + nixpkgs.config.allowUnfree = true; + + # Change build dir to /var/tmp + systemd.services.nix-daemon = { + environment.TMPDIR = lib.mkDefault "/var/tmp"; + }; + + # This value determines the NixOS release with which your system is to be + # compatible, in order to avoid breaking some software such as database + # servers. You should change this only after NixOS release notes say you + # should. + system.stateVersion = lib.mkDefault "23.11"; # Did you read the comment? + }; +}