forked from fediversity/fediversity
		
	this gets rid of ugly in-place imports and upward paths Reviewed-on: Fediversity/Fediversity#464 Reviewed-by: kiara Grouwstra <kiara@procolix.eu> Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io> Co-committed-by: Valentin Gagarin <valentin.gagarin@tweag.io>
		
			
				
	
	
		
			58 lines
		
	
	
	
		
			1.5 KiB
		
	
	
	
		
			Nix
		
	
	
	
	
	
			
		
		
	
	
			58 lines
		
	
	
	
		
			1.5 KiB
		
	
	
	
		
			Nix
		
	
	
	
	
	
{
 | 
						|
  system ? builtins.currentSystem,
 | 
						|
  sources ? import ../npins,
 | 
						|
  pkgs ? import sources.nixpkgs {
 | 
						|
    inherit system;
 | 
						|
    config = { };
 | 
						|
    overlays = [ (import ./nix/overlay.nix) ];
 | 
						|
  },
 | 
						|
}:
 | 
						|
let
 | 
						|
  inherit (pkgs) lib;
 | 
						|
  manage = pkgs.writeScriptBin "manage" ''
 | 
						|
    exec ${pkgs.lib.getExe pkgs.python3} ${toString ./src/manage.py} $@
 | 
						|
  '';
 | 
						|
  package = pkgs.callPackage ./nix/package.nix { };
 | 
						|
in
 | 
						|
{
 | 
						|
  shell = pkgs.mkShellNoCC {
 | 
						|
    inputsFrom = [ package ];
 | 
						|
    packages = [
 | 
						|
      pkgs.npins
 | 
						|
      manage
 | 
						|
 | 
						|
      # NixOps4 and its dependencies
 | 
						|
      pkgs.nixops4
 | 
						|
      pkgs.nix
 | 
						|
      pkgs.openssh
 | 
						|
    ];
 | 
						|
    env = {
 | 
						|
      DEPLOYMENT_FLAKE = toString ../.;
 | 
						|
      DEPLOYMENT_NAME = "test";
 | 
						|
      NPINS_DIRECTORY = toString ../npins;
 | 
						|
      CREDENTIALS_DIRECTORY = toString ./.credentials;
 | 
						|
      DATABASE_URL = "sqlite:///${toString ./src}/db.sqlite3";
 | 
						|
    };
 | 
						|
    shellHook = ''
 | 
						|
      ${lib.concatStringsSep "\n" (
 | 
						|
        map (file: "ln -sf ${file.from} ${toString ./src/${file.to}}") package.generated
 | 
						|
      )}
 | 
						|
 | 
						|
      # in production, secrets are passed via CREDENTIALS_DIRECTORY by systemd.
 | 
						|
      # use this directory for testing with local secrets
 | 
						|
      mkdir -p $CREDENTIALS_DIRECTORY
 | 
						|
      echo secret > ${builtins.toString ./.credentials}/SECRET_KEY
 | 
						|
    '';
 | 
						|
  };
 | 
						|
 | 
						|
  module = ./nix/configuration.nix;
 | 
						|
  tests = pkgs.callPackage ./nix/tests.nix { };
 | 
						|
 | 
						|
  # re-export inputs so they can be overridden granularly
 | 
						|
  # (they can't be accessed from the outside any other way)
 | 
						|
  inherit
 | 
						|
    sources
 | 
						|
    system
 | 
						|
    pkgs
 | 
						|
    ;
 | 
						|
}
 |