[Nix-dev] Import remote packages in NixOps/NixOS

Eric Sagnes eric.sagnes at gmail.com
Wed Mar 9 00:15:49 CET 2016


Thank you, it works perfectly with the `{}` at the end of the import!

On Tue, Mar 08, 2016 at 05:24:02PM +0100, Rok Garbas wrote:
> Hi,
> 
> On Tue, Mar 8, 2016 at 6:42 AM, Eric Sagnes <eric.sagnes at gmail.com> wrote:
> > It is possible to import foreign modules in NixOps by doing:
> >
> > ```
> > {
> >   network.description = "Web server";
> >
> >   webserver = { config, pkgs, ... }:
> >     let
> >       myModuleSrc = (import <nixpkgs> {}).fetchFromGitHub {
> >           owner  = "me";
> >           repo   = "myModule";
> >           rev    = "v1.0";
> >           sha256 = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
> >       };
> >     in
> >     {
> >       imports = [ "${myModuleSrc}/module.nix" ];
> >       services.myModule.enable = true;
> >     };
> > }
> > ```
> >
> > Presupposing that the remote package provides a nix build expression,
> > is it possible to directly import it in a similar way?
> > Pseudo code that is not working:
> >
> > ```
> > {
> >   network.description = "Web server";
> >
> >   webserver = { config, pkgs, ... }:
> >     let
> >       myPackageSrc = (import <nixpkgs> {}).fetchFromGitHub {
> >           owner  = "me";
> >           repo   = "myPackage";
> >           rev    = "v1.0";
> >           sha256 = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
> >       };
> >     in
> >     {
> >       environment.systemPackages = [
> >         (import "${myPackageSrc}/release.nix")
> >       ];
> >
> >     };
> > }
> > ```
> >
> > (The above complains about coercing a function to a string.)
> >
> 
> 
> you can also just use builtins.fetchFromTarball.
> 
> for above you probably will want to do
> 
>   (import "${myPackagesSrc}/release.nix" { ... })
> 
> 
> -- 
> Rok Garbas - https://.garbas.si

-- 
Eric Sagnes
サニエ エリック


More information about the nix-dev mailing list