diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..b5e1171 --- /dev/null +++ b/default.nix @@ -0,0 +1,14 @@ +# It should return a set of nix derivations +# and optionally the special attributes `lib`, `modules` and `overlays`. +# It should NOT import . Instead, you should take pkgs as an argument. +# Having pkgs default to is fine though, and it lets you use short +# commands such as: +# nix-build -A mypackage + +{ pkgs ? import {} }: + + +{ + overlays = import ./nix/overlays; + pkgs = import ./nix/pkgs { inherit pkgs; }; +} diff --git a/nix/home-manager/profiles/common.nix b/nix/home-manager/profiles/common.nix index 3db0a6a..43c25c2 100644 --- a/nix/home-manager/profiles/common.nix +++ b/nix/home-manager/profiles/common.nix @@ -8,9 +8,7 @@ in { # programs.home-manager.enable = true; # programs.home-manager.path = https://github.com/rycee/home-manager/archive/445c0b1482c38172a9f8294ee16a7ca7462388e5.tar.gz; - nixpkgs.overlays = [ - (import ../../overlay.nix) - ]; + nixpkgs.overlays = builtins.attrValues (import ../../overlays); nixpkgs.config = { allowBroken = true; diff --git a/nix/os/profiles/common/configuration.nix b/nix/os/profiles/common/configuration.nix index 63c44de..361f538 100644 --- a/nix/os/profiles/common/configuration.nix +++ b/nix/os/profiles/common/configuration.nix @@ -1,9 +1,7 @@ { ... }: { - nixpkgs.overlays = [ - (import ../../../overlay.nix) - ]; + nixpkgs.overlays = builtins.attrValues (import ../../../overlays); imports = [ ./boot.nix diff --git a/nix/os/profiles/containers/configuration.nix b/nix/os/profiles/containers/configuration.nix index b6f3f61..89a5fe4 100644 --- a/nix/os/profiles/containers/configuration.nix +++ b/nix/os/profiles/containers/configuration.nix @@ -1,9 +1,7 @@ { ... }: { - nixpkgs.overlays = [ - (import ../../../overlay.nix) - ]; + nixpkgs.overlays = builtins.attrValues (import ../../../overlays); imports = [ ../../modules/ddclient-ovh.nix diff --git a/nix/overlay.nix b/nix/overlay.nix deleted file mode 100644 index 2f20583..0000000 --- a/nix/overlay.nix +++ /dev/null @@ -1,105 +0,0 @@ -self: super: - -let - nixpkgs-master = import {}; - - # one application requires php5 - nixpkgsWithPhp5 = super.fetchFromGitHub { - owner = "nixos"; - repo = "nixpkgs-channels"; - rev = "846d8f8305192dcc3a63139102698b4ac6b9ef9f"; - sha256 = "1qifgc1q2i4g0ivpfjnxp4jl2cc82gfjws08dsllgw7q7kw4b4rb"; - }; - -in { - # alacritty = nixpkgs-master.alacritty; - alacritty = super.stdenv.mkDerivation { - name = "alacritty-custom"; - buildInputs = [ super.makeWrapper ]; - phases = "installPhase"; - installPhase = '' - makeWrapper ${nixpkgs-master.alacritty}/bin/alacritty $out/bin/alacritty \ - --set-default WINIT_HIDPI_FACTOR 1.0 - ''; - }; - - duplicacy = super.callPackage ./pkgs/duplicacy {}; - just = super.callPackage ./pkgs/just.nix {}; - mfcl3770cdw = super.callPackage ./pkgs/mfcl3770cdw.nix {}; - staruml = super.callPackage ./pkgs/staruml.nix { inherit (super.gnome2) GConf; libgcrypt = super.libgcrypt_1_5; }; - - roxterm = super.stdenv.mkDerivation { - name = "roxterm-custom"; - buildInputs = [ super.makeWrapper ]; - phases = "installPhase"; - installPhase = '' - makeWrapper ${super.roxterm}/bin/roxterm $out/bin/roxterm \ - --add-flags "--separate" - ''; - }; - - busyboxStatic = super.busybox.override { - enableStatic = true; - extraConfig = '' - CONFIG_STATIC y - CONFIG_INSTALL_APPLET_DONT y - CONFIG_INSTALL_APPLET_SYMLINKS n - ''; - }; - dropbearStatic = super.dropbear.override { - enableStatic = true; - }; - - php56 = (super.callPackages - "${nixpkgsWithPhp5}/pkgs/development/interpreters/php/default.nix" {}) - .php56.overrideAttrs(drv: rec { - # See https://secure.php.net/ChangeLog-5.php - version = "5.6.40"; - name = "php-${version}"; - - sha256 = "005s7w167dypl41wlrf51niryvwy1hfv53zxyyr3lm938v9jbl7z"; - src = super.fetchurl { - url = "http://www.php.net/distributions/php-${version}.tar.bz2"; - inherit sha256; - }; - }); - - rdedup = super.callPackages ./pkgs/rdedup {}; - - # TODO: facetimehd is currfently broken (https://github.com/NixOS/nixpkgs/pull/72804) - facetimehd-firmware = super.hello; - - qtile = nixpkgs-master.qtile; - - inherit (nixpkgs-master) podman conmon slirp4netns; - - # posh makes use of podman to run an encapsulated shell session - posh = { image, pull ? "always", global_args ? "", run_args ? "" }: - (super.writeScriptBin "posh" '' - #! ${super.bash}/bin/bash - source /etc/profile - - test -S "$SSH_AUTH_SOCK" && ssh="-v $SSH_AUTH_SOCK:$SSH_AUTH_SOCK -e SSH_AUTH_SOCK" - tty -s && tty="-t" || quiet="-q" - - # define these as variables so we can override them at runtime - POSH_IMAGE=${image} - POSH_PULL=${pull} - - if [ "$1" == "-c" ]; then - # We've most likely been spawned by sshd and are interested in $2 whitch contains the command string - shift - # TODO parse the beginning of the command for POSH_* overrides - fi - - exec ${self.podman}/bin/podman \ - ${global_args} run --rm -i $tty $ssh -v ~/:/root -w /root --network host --pull=''${POSH_PULL} \ - ${run_args} ''${POSH_IMAGE} $@ - '') - .overrideAttrs(attrs: attrs // { - passthru = { - shellPath = "/bin/posh"; - }; - }); - -} diff --git a/nix/overlays/default.nix b/nix/overlays/default.nix new file mode 100644 index 0000000..e412c8d --- /dev/null +++ b/nix/overlays/default.nix @@ -0,0 +1,5 @@ +{ + overrides = import ./overrides.nix; + pkgs = import ./pkgs.nix; + posh = import ./posh.nix; +} diff --git a/nix/overlays/overrides.nix b/nix/overlays/overrides.nix new file mode 100644 index 0000000..0e00859 --- /dev/null +++ b/nix/overlays/overrides.nix @@ -0,0 +1,36 @@ +# This overlay is used for overriding upstream packages. + +self: super: + +let + nixpkgs-master = import { inherit (super) config; }; + +in { + inherit nixpkgs-master; + + # alacritty = nixpkgs-master.alacritty; + alacritty = super.stdenv.mkDerivation { + name = "alacritty-custom"; + buildInputs = [ super.makeWrapper ]; + phases = "installPhase"; + installPhase = '' + makeWrapper ${self.nixpkgs-master.alacritty}/bin/alacritty $out/bin/alacritty \ + --set-default WINIT_HIDPI_FACTOR 1.0 + ''; + }; + + roxterm = super.stdenv.mkDerivation { + name = "roxterm-custom"; + buildInputs = [ super.makeWrapper ]; + phases = "installPhase"; + installPhase = '' + makeWrapper ${super.roxterm}/bin/roxterm $out/bin/roxterm \ + --add-flags "--separate" + ''; + }; + + # TODO: facetimehd is currfently broken (https://github.com/NixOS/nixpkgs/pull/72804) + facetimehd-firmware = super.hello; + + qtile = self.nixpkgs-master.qtile; +} diff --git a/nix/overlays/pkgs.nix b/nix/overlays/pkgs.nix new file mode 100644 index 0000000..b6b57ef --- /dev/null +++ b/nix/overlays/pkgs.nix @@ -0,0 +1,18 @@ +# This overlay includes all packages defined by the top-level default.nix. +# The code is copied from the NUR repository [0]. +# +# [0]: https://github.com/nix-community/nur-packages-template/blob/2610a5b60bd926cea3e6395511da8f0d14c613b9/overlay.nix + +self: super: + +let + + isReserved = n: n == "lib" || n == "overlays" || n == "modules"; + nameValuePair = n: v: { name = n; value = v; }; + nurAttrs = import ../pkgs { pkgs = super; }; + +in + builtins.listToAttrs + (map (n: nameValuePair n nurAttrs.${n}) + (builtins.filter (n: !isReserved n) + (builtins.attrNames nurAttrs))) diff --git a/nix/overlays/posh.nix b/nix/overlays/posh.nix new file mode 100644 index 0000000..441922d --- /dev/null +++ b/nix/overlays/posh.nix @@ -0,0 +1,8 @@ +self: super: + +let + nixpkgs-master = import {}; +in { + inherit (nixpkgs-master) podman conmon slirp4netns; + posh = self.callPackage ../pkgs/posh.nix {}; +} diff --git a/nix/pkgs/default.nix b/nix/pkgs/default.nix new file mode 100644 index 0000000..f1c275a --- /dev/null +++ b/nix/pkgs/default.nix @@ -0,0 +1,70 @@ +{ pkgs }: +let + # one application requires php5 + nixpkgsWithPhp5 = pkgs.fetchFromGitHub { + owner = "nixos"; + repo = "nixpkgs-channels"; + rev = "846d8f8305192dcc3a63139102698b4ac6b9ef9f"; + sha256 = "1qifgc1q2i4g0ivpfjnxp4jl2cc82gfjws08dsllgw7q7kw4b4rb"; + }; + +in rec { + nixpkgs-master = import {}; + + linuxPackages_sgx_540rc3 = let + linux_sgx_pkg = { fetchurl, buildLinux, ... } @ args: + + buildLinux (args // rec { + version = "5.4.0-rc3"; + modDirVersion = version; + + src = fetchurl { + url = "https://github.com/jsakkine-intel/linux-sgx/archive/v23.tar.gz"; + sha256 = "11rwlwv7s071ia889dk1dgrxprxiwgi7djhg47vi56dj81jgib20"; + }; + kernelPatches = []; + + extraConfig = '' + INTEL_SGX y + ''; + + extraMeta.branch = "5.4"; + } // (args.argsOverride or {})); + linux_sgx = pkgs.callPackage linux_sgx_pkg {}; + in + pkgs.recurseIntoAttrs (pkgs.linuxPackagesFor linux_sgx); + linuxPackages_sgx_latest = linuxPackages_sgx_540rc3; + + rdedup = pkgs.callPackages ../pkgs/rdedup {}; + + busyboxStatic = pkgs.busybox.override { + enableStatic = true; + extraConfig = '' + CONFIG_STATIC y + CONFIG_INSTALL_APPLET_DONT y + CONFIG_INSTALL_APPLET_SYMLINKS n + ''; + }; + dropbearStatic = pkgs.dropbear.override { + enableStatic = true; + }; + + php56 = (pkgs.callPackages + "${nixpkgsWithPhp5}/pkgs/development/interpreters/php/default.nix" {}) + .php56.overrideAttrs(drv: rec { + # See https://secure.php.net/ChangeLog-5.php + version = "5.6.40"; + name = "php-${version}"; + + sha256 = "005s7w167dypl41wlrf51niryvwy1hfv53zxyyr3lm938v9jbl7z"; + src = pkgs.fetchurl { + url = "http://www.php.net/distributions/php-${version}.tar.bz2"; + inherit sha256; + }; + }); + + duplicacy = pkgs.callPackage ../pkgs/duplicacy {}; + just = pkgs.callPackage ../pkgs/just.nix {}; + mfcl3770cdw = pkgs.callPackage ../pkgs/mfcl3770cdw.nix {}; + staruml = pkgs.callPackage ../pkgs/staruml.nix { inherit (pkgs.gnome2) GConf; libgcrypt = pkgs.libgcrypt_1_5; }; +} diff --git a/nix/pkgs/posh.nix b/nix/pkgs/posh.nix new file mode 100644 index 0000000..043895b --- /dev/null +++ b/nix/pkgs/posh.nix @@ -0,0 +1,32 @@ +# posh makes use of podman to run an encapsulated shell session +{ pkgs, ... }: + +{ image, pull ? "always", global_args ? "", run_args ? "" }: + + +(pkgs.writeScriptBin "posh" '' + #! ${pkgs.bash}/bin/bash + source /etc/profile + + test -S "$SSH_AUTH_SOCK" && ssh="-v $SSH_AUTH_SOCK:$SSH_AUTH_SOCK -e SSH_AUTH_SOCK" + tty -s && tty="-t" || quiet="-q" + + # define these as variables so we can override them at runtime + POSH_IMAGE=${image} + POSH_PULL=${pull} + + if [ "$1" == "-c" ]; then + # We've most likely been spawned by sshd and are interested in $2 whitch contains the command string + shift + # TODO parse the beginning of the command for POSH_* overrides + fi + + exec ${pkgs.podman}/bin/podman \ + ${global_args} run --rm -i $tty $ssh -v ~/:/root -w /root --network host --pull=''${POSH_PULL} \ + ${run_args} ''${POSH_IMAGE} $@ +'') +.overrideAttrs(attrs: attrs // { + passthru = { + shellPath = "/bin/posh"; + }; +}) diff --git a/shell.nix b/shell.nix index 5ccc005..2ece22a 100644 --- a/shell.nix +++ b/shell.nix @@ -2,7 +2,7 @@ let channels-nixos-stable-path = (builtins.fetchTarball https://github.com/NixOS/nixpkgs-channels/archive/7e88992a8c7b2de0bcb89182d8686b27bd93e46a.tar.gz); - channels-nixos-stable = import channels-nixos-stable-path { overlays = [ (import ./nix/overlay.nix) ]; }; + channels-nixos-stable = import channels-nixos-stable-path { overlays = builtins.attrValues (import ./nix/overlays); }; in with channels-nixos-stable;