Skip to content

Instantly share code, notes, and snippets.

@jefdaj
Last active February 15, 2022 12:38
Show Gist options
  • Save jefdaj/9c88c5f9712f33faf7b1 to your computer and use it in GitHub Desktop.
Save jefdaj/9c88c5f9712f33faf7b1 to your computer and use it in GitHub Desktop.
Draft nix expression to wrap debian packages.
source $stdenv/setup
PATH=$dpkg/bin:$PATH
dpkg -x $src unpacked
cp -r unpacked/* $out/
{ self, derive }: with self; {
hello = derive { name="hello-traditional"; version="2.9-2"; script="hello"; md5="f5f3c28b65221dae44dda6f242c23316"; };
}
with import <nixpkgs> {};
# Draft nix expression to wrap debian packages.
# Written by Jeff Johnson based on r-modules.nix and this blog post:
# http://anderspapitto.com/posts/2015-02-28-deb-installation-nixos.html
# TODO: how to infer the "main/h" part of the url?
# TODO: sha256 instead of md5
# TODO: make deb2nix?
# TODO: multiple architectures
# TODO: can the script name be inferred? can you have more than one?
# TODO: include a list of dependencies in the packages desc
let
self = import ./debian-packages.nix { inherit self; derive = mkDebianPackage; };
mkDebianPackage = desc: let
deb = mkPkg desc;
mkUrl = { name, version}:
"http://ftp.us.debian.org/debian/pool/main/h/${name}/${name}_${version}_amd64.deb";
mkPkg = pkg: stdenv.mkDerivation (pkg // {
inherit dpkg;
builder = ./builder.sh;
runScript = "${pkg.script} $@";
src = fetchurl {
url = mkUrl { inherit (desc) name version; };
inherit (desc) md5;
};
});
in buildFHSUserEnv {
inherit (deb) name runScript;
targetPkgs = pkgs: [ deb ];
multiPkgs = pkgs: [ pkgs.dpkg ];
};
in self
@RudraveerMandal
Copy link

Perfection

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment