Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jakub Sokołowski <jakub@status.im>
- Loading branch information
Showing
2 changed files
with
129 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
pipeline { | ||
agent { | ||
/* the -u is necessary for acces to /nix */ | ||
docker { | ||
label 'linux' | ||
image 'nixos/nix' | ||
args '-u 0:0' | ||
} | ||
} | ||
|
||
environment { | ||
/* we source .bash_profile to be able to use nix-store */ | ||
NIX_SSHOPTS="-o StrictHostKeyChecking=no source .bash_profile;" | ||
/* where our /nix/store is hosted */ | ||
NIX_CACHE_USER = 'nix-cache' | ||
NIX_CACHE_HOST = 'master-01.do-ams3.ci.misc.statusim.net' | ||
/* we add both keys so default binary cache also works */ | ||
NIX_BIN_CACHE = 'https://nix-cache.status.im/' | ||
NIX_BIN_CACHE_KEYS = ( | ||
'nix-cache.status.im-1:x/93lOfLU+duPplwMSBR+OlY4+mo+dCN7n0mr4oPwgY= '+ | ||
'cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=' | ||
) | ||
} | ||
|
||
options { | ||
timestamps() | ||
disableConcurrentBuilds() | ||
/* Prevent Jenkins jobs from running forever */ | ||
timeout(time: 20, unit: 'MINUTES') | ||
/* Limit builds retained */ | ||
buildDiscarder(logRotator( | ||
numToKeepStr: '20', | ||
daysToKeepStr: '30', | ||
)) | ||
} | ||
|
||
stages { | ||
stage('Setup') { | ||
steps { | ||
sh 'nix-env -i openssh' | ||
} | ||
} | ||
stage('Build') { | ||
steps { | ||
/* we dogfood our own cache to speed up builds */ | ||
sh """ | ||
nix-build -A env \ | ||
--option extra-substituters '${NIX_BIN_CACHE}' \ | ||
--trusted-public-keys '${NIX_BIN_CACHE_KEYS}' | ||
""" | ||
} | ||
} | ||
stage('Upload') { | ||
steps { | ||
sshagent(credentials: ['nix-cache-ssh']) { | ||
sh """ | ||
find /nix/store/ -mindepth 1 -maxdepth 1 -not -name '.links' | \ | ||
xargs nix-copy-closure -v --to ${NIX_CACHE_USER}@${NIX_CACHE_HOST} | ||
""" | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
pipeline { | ||
agent { | ||
label 'macos' | ||
} | ||
|
||
environment { | ||
/* we source .bash_profile to be able to use nix-store */ | ||
NIX_SSHOPTS="-o StrictHostKeyChecking=no source .bash_profile;" | ||
/* where our /nix/store is hosted */ | ||
NIX_CACHE_USER = 'nix-cache' | ||
NIX_CACHE_HOST = 'master-01.do-ams3.ci.misc.statusim.net' | ||
/* we add both keys so default binary cache also works */ | ||
NIX_BIN_CACHE = 'https://nix-cache.status.im/' | ||
NIX_BIN_CACHE_KEYS = ( | ||
'nix-cache.status.im-1:x/93lOfLU+duPplwMSBR+OlY4+mo+dCN7n0mr4oPwgY= '+ | ||
'cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=' | ||
) | ||
} | ||
|
||
options { | ||
timestamps() | ||
disableConcurrentBuilds() | ||
/* Prevent Jenkins jobs from running forever */ | ||
timeout(time: 120, unit: 'MINUTES') | ||
/* Limit builds retained */ | ||
buildDiscarder(logRotator( | ||
numToKeepStr: '20', | ||
daysToKeepStr: '30', | ||
)) | ||
} | ||
|
||
stages { | ||
stage('Setup') { | ||
steps { | ||
sh 'make setup' | ||
sh """ | ||
. ~/.nix-profile/etc/profile.d/nix.sh && \ | ||
nix-env -i openssh | ||
""" | ||
} | ||
} | ||
stage('Build') { | ||
steps { | ||
/* we dogfood our own cache to speed up builds */ | ||
sh """ | ||
. ~/.nix-profile/etc/profile.d/nix.sh && \ | ||
nix-build -A env \ | ||
--option extra-substituters '${NIX_BIN_CACHE}' \ | ||
--trusted-public-keys '${NIX_BIN_CACHE_KEYS}' | ||
""" | ||
} | ||
} | ||
stage('Upload') { | ||
steps { | ||
sshagent(credentials: ['nix-cache-ssh']) { | ||
sh """ | ||
. ~/.nix-profile/etc/profile.d/nix.sh && \ | ||
find /nix/store/ -mindepth 1 -maxdepth 1 -not -name '.links' | \ | ||
xargs nix-copy-closure -v --to ${NIX_CACHE_USER}@${NIX_CACHE_HOST} | ||
""" | ||
} | ||
} | ||
} | ||
} | ||
} |