Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,22 @@ store_paths=$(find . -name default.nix | grep -v '^./nix' | grep -v '^./dist-ne
layout_dir=$(direnv_layout_dir)
env_dir=./.env

# The env_dir used to be a symlink to env in nix store, if it exists, delete it.
[[ ! -L "$env_dir" ]] || rm -f "$env_dir"

[[ -d "$layout_dir" ]] || mkdir -p "$layout_dir"

if [[ ! -d "$env_dir" || ! -f "$layout_dir/nix-rebuild" || "$store_paths" != $(< "$layout_dir/nix-rebuild" ) ]]; then

[[ -d "$env_dir" ]] || mkdir -p "$env_dir"

# this builds "wireServer.devShell" defined in ./nix/default.nix and outputs to ./.env
nix-shell ./nix -A wireServer.devShell --run 'direnv dump bash' > "${env_dir}/dev-shell.sh"

nix-build ./nix -A profileEnv --out-link "${env_dir}/profile-env"
nix-build ./nix -A wireServer.devEnv --out-link ./.env

echo "$store_paths" > "$layout_dir/nix-rebuild"
fi

source_env "${env_dir}/dev-shell.sh"
PATH_add "./.env/bin"
path_add "PKG_CONFIG_PATH" "./.env/lib/pkgconfig"
path_add "LIBRARY_PATH" "./.env/lib"

# source .profile from `$env`. This sets NIX_PATH to pkgs defined in
# ./nix/default.nix. Tis is useful for nix tooling that runs inside this direnv,
# e.g. "nix-shell -p foo" will get "foo" for pkgs defined in ./nix/default.nix
[[ -f "${env_dir}/profile-env/.profile" ]] && source_env "${env_dir}/profile-env/.profile"
[[ -f "./.env/.profile" ]] && source_env "./.env/.profile"

# allow local .envrc overrides
[[ -f .envrc.local ]] && source_env .envrc.local
Expand Down
2 changes: 1 addition & 1 deletion changelog.d/0-release-notes/nix-builds
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Build docker images using nix derivations instead of Dockerfiles (#2331, #2771, #2772, #2775)
Build docker images using nix derivations instead of Dockerfiles (#2331, #2771, #2772, #2775, #2776)
44 changes: 31 additions & 13 deletions nix/wire-server.nix
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ let lib = pkgs.lib;

gitignoreSource =
let gitignoreSrc = pkgs.fetchFromGitHub {
owner = "hercules-ci";
repo = "gitignore.nix";
# put the latest commit sha of gitignore Nix library here:
rev = "a20de23b925fd8264fd7fad6454652e142fd7f73";
# use what nix suggests in the mismatch message here:
sha256 = "sha256:07vg2i9va38zbld9abs9lzqblz193vc5wvqd6h7amkmwf66ljcgh";
};
owner = "hercules-ci";
repo = "gitignore.nix";
# put the latest commit sha of gitignore Nix library here:
rev = "a20de23b925fd8264fd7fad6454652e142fd7f73";
# use what nix suggests in the mismatch message here:
sha256 = "sha256:07vg2i9va38zbld9abs9lzqblz193vc5wvqd6h7amkmwf66ljcgh";
};
in (import gitignoreSrc { inherit (pkgs) lib; }).gitignoreSource;

# Mapping from package -> [executable]
Expand Down Expand Up @@ -291,6 +291,21 @@ let lib = pkgs.lib;
experimental-features = "nix-command";
};
};

shell = (hPkgs localModsOnlyTests).shellFor {
packages = p: builtins.map (e: p.${e}) wireServerPackages;
};
ghcWithPackages = shell.nativeBuildInputs ++ shell.buildInputs;

profileEnv = pkgs.writeTextFile {
name = "profile-env";
destination = "/.profile";
# This gets sourced by direnv. Set NIX_PATH, so `nix-shell` uses the same nixpkgs as here.
text = ''
export NIX_PATH=nixpkgs=${toString pkgs.path}
export LOCALE_ARCHIVE=${pkgs.glibcLocales}/lib/locale/locale-archive
'';
};
in {
inherit ciImage hoogleImage;

Expand All @@ -303,11 +318,11 @@ in {
enableTests = true;
enableDocs = false;
};
imagesList = imagesList;
inherit imagesList;

devShell = (hPkgs localModsOnlyTests).shellFor {
packages = p: builtins.map (e: p.${e}) wireServerPackages;
buildInputs = commonTools ++ [
devEnv = pkgs.buildEnv {
name = "wire-server-dev-env";
paths = commonTools ++ [
(pkgs.haskell-language-server.override { supportedGhcVersions = [ "8107" ]; })
pkgs.ghcid
pkgs.cfssl
Expand All @@ -322,13 +337,16 @@ in {
pkgs.cabal-install
pkgs.haskellPackages.cabal-plan
pkgs.nix-prefetch-git
] ++ pkgs.lib.optionals pkgs.stdenv.isLinux [
profileEnv
]
++ ghcWithPackages
++ pkgs.lib.optionals pkgs.stdenv.isLinux [
# linux-only, not strictly required tools

pkgs.docker-compose
pkgs.telepresence
];
};

inherit brig-templates;
haskellPackages = hPkgs localModsEnableAll;
haskellPackagesUnoptimizedNoDocs = hPkgs localModsOnlyTests;
Expand Down