From c31fb8b184df21662f6cae2dfe3e07167a32a799 Mon Sep 17 00:00:00 2001 From: Minijackson Date: Thu, 3 Oct 2019 17:56:17 +0200 Subject: nixos conf examples, how to override them and embedded usecase --- res/cross-build-1.nix | 44 ++++++++++++++++++++++++++++++++++++++++++++ res/cross-build-2.nix | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 res/cross-build-1.nix create mode 100644 res/cross-build-2.nix (limited to 'res') diff --git a/res/cross-build-1.nix b/res/cross-build-1.nix new file mode 100644 index 0000000..0598129 --- /dev/null +++ b/res/cross-build-1.nix @@ -0,0 +1,44 @@ +{ nixpkgs ? import , ... }: + +let + pkgs = nixpkgs { + config = { }; + # https://github.com/NixOS/nixpkgs/blob/master/lib/systems/examples.nix + crossSystem = { + config = "armv7l-unknown-linux-gnueabihf"; + }; + #overlays = [ (import ./overlay.nix) ]; + }; + + config = { ... }: + { + environment.noXlibs = true; + documentation.enable = false; + + # btrfs-progs fails to build + services.udisks2.enable = false; + + fonts.fontconfig.enable = false; + + nixpkgs.overlays = with pkgs.lib; singleton (const (super: { + polkit = super.polkit.override { withGnome = false; }; + + # pkcs11 needs opensc which depends on libXt? which fails to build and is X library + rng-tools = super.rng-tools.override { withPkcs11 = false; }; + + nix = super.nix.override { withAWS = false; }; + })); + + fileSystems."/".fsType = "tmpfs"; + + boot = { + loader.grub.enable = false; + enableContainers = false; + hardwareScan = false; + }; + + powerManagement.enable = false; + }; + +in + pkgs.nixos config diff --git a/res/cross-build-2.nix b/res/cross-build-2.nix new file mode 100644 index 0000000..7225964 --- /dev/null +++ b/res/cross-build-2.nix @@ -0,0 +1,46 @@ +# This one is much better than the first +# +# TODO: get `nix build -f cross-build-2.nix vm` to work + +{ nixos ? import , ... }: + +let + # https://github.com/NixOS/nixpkgs/blob/master/lib/systems/examples.nix + target = "armv7l-unknown-linux-gnueabihf"; + + configuration = { lib, ... }: + { + nixpkgs.crossSystem = lib.systems.elaborate { config = target; }; + nixpkgs.overlays = with lib; singleton (const (super: { + polkit = super.polkit.override { withGnome = false; }; + + # pkcs11 needs opensc which depends on libXt? which fails to build and is X library + rng-tools = super.rng-tools.override { withPkcs11 = false; }; + + nix = super.nix.override { withAWS = false; }; + + gobject-introspection = super.callPackage /tmp/gobject-introspection.nix { inherit (darwin) cctools; }; + })); + + + environment.noXlibs = true; + documentation.enable = false; + + # btrfs-progs fails to build + services.udisks2.enable = false; + + fonts.fontconfig.enable = false; + + fileSystems."/".fsType = "tmpfs"; + + boot = { + loader.grub.enable = false; + enableContainers = false; + hardwareScan = false; + }; + + powerManagement.enable = false; + }; + +in + nixos { inherit configuration; } -- cgit v1.2.3