Skip to content

Instantly share code, notes, and snippets.

@ocharles
Created October 25, 2018 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ocharles/44aedf2a1692534ab719db2570938589 to your computer and use it in GitHub Desktop.
Save ocharles/44aedf2a1692534ab719db2570938589 to your computer and use it in GitHub Desktop.
{ src, ... }:
let
system-pkgs =
system: import ../nix/pkgs { inherit system; };
in
let pkgs = system-pkgs "x86_64-linux"; in
let
build-system =
system: f:
f ( system-pkgs system );
in
let
filtered =
builtins.filterSource
( name: type:
type == "directory" || pkgs.lib.hasSuffix ".cabal" (baseNameOf name)
)
./..;
cabal-files =
pkgs.runCommand
"find-cabal-files"
{}
''
echo "[" > $out
find ${filtered} -name '*.cabal' >> $out
echo "]" >> $out
'';
networks =
{ mycronic =
pkgs.lib.mapAttrs
( _: system:
import
../factory-infrastructure/mycronic/activator.nix
{ inherit system; }
)
{ my300 = ../factory-infrastructure/mycronic/my300.nix;
my700 = ../factory-infrastructure/mycronic/my700.nix;
robot = ../factory-infrastructure/mycronic/robot.nix;
tpsys = ../factory-infrastructure/mycronic/tpsys.nix;
};
}
//
pkgs.lib.mapAttrs
( _: configuration:
let
network =
import
"${pkgs.nixops}/share/nix/nixops/eval-machine-info.nix"
{ networkExprs = configuration;
uuid = "04df9e6f-4c43-40f4-8a45-0a172e70ebcb";
args = {};
deploymentName = "ci";
};
in
pkgs.lib.mapAttrs
( _: node: node.config.system.build.toplevel )
network.nodes
)
{ coordinator =
[ ../picofactory/coordinator/infrastructure/coordinator.nix ];
"deploy-circuithub-com" =
[ ../infrastructure/coordinator.nix
../infra-2/networks/internal/coordinator-physical.nix
];
internal =
[ ../infrastructure/hydra.nix
../infra-2/networks/internal/physical.nix
];
"circuithub-com" =
[ ../infrastructure/production/new.nix
../infrastructure/production/api.nix
../infra-2/networks/production/physical.nix
];
picofactory-knowledge-stations =
[ ../factory-infrastructure/knowledge-stations/deploy.nix
];
picofactory-network =
[ ../factory-infrastructure/vpn/deploy.nix
../factory-infrastructure/vpn/physical.nix
];
picofactory-stations =
[ ../factory-infrastructure/picofactory-stations/deploy.nix
../factory-infrastructure/picofactory-stations/physical.nix
];
vault =
[ ../infrastructure/vault/network.nix
];
};
system-jobs =
pkgs.lib.mapAttrs build-system
{
"x86_64-linux" =
pkgs:
rec {
deployables =
{ inherit ( pkgs.circuithub )
circuithub-api
client
coordinator
pallet-loader
projects
remote-mouse
ur10;
};
haskell =
pkgs.lib.listToAttrs
( map
( cabal-file:
let
package-name =
pkgs.lib.removeSuffix ".cabal" ( baseNameOf cabal-file );
in
{ name = package-name;
value = pkgs.haskellPackages."${package-name}";
}
)
( import cabal-files )
);
hlint =
pkgs.lib.mapAttrs
( name: drv:
let
# We don't need dependencies to HLint source code.
noDeps =
pkgs.lib.overrideDerivation drv ( drv: {
configurePhase = ":";
buildInputs = [];
propagatedBuildInputs = [];
} );
in
pkgs.lib.overrideDerivation
# Only HLint things we actually need.
( pkgs.haskell.lib.buildFromSdist noDeps )
( drv:
{ name = "${drv.name}-hlint";
outputs = [ "out" ];
configurePhase = ":";
preConfigurePhases = []; # Avoids building Setup
buildInputs = [ pkgs.haskellPackages.hlint ];
buildPhase = "touch .hlint.yml && hlint -h ${../hlint.yml} .";
installPhase = "touch $out";
haddockPhase = ":";
checkPhase = ":";
fixupPhase = ":";
}
)
)
haskell;
};
"i686-linux" =
pkgs:
{
deployables =
{ inherit ( pkgs.circuithub ) linescan-image-archiver my300-hwi-rewrite
remote-mouse ur10;
};
};
};
jobs =
{
inherit ( system-jobs ) "x86_64-linux" "i686-linux";
inherit networks;
shell =
pkgs.releaseTools.aggregate {
name = "shell-inputs";
constituents = (import ../shell.nix {}).buildInputs;
};
circuithub-client-elm-doc =
pkgs.callPackage ../client/doc/build.nix {};
client-elm-tests =
(pkgs.callPackage ../client/jobs.nix { AWS_KEY=null; AWS_SECRET=null;}).client-elm-tests;
pythonPackages.aoi =
pkgs.runCommand
"pyflakes-aoi"
{ buildInputs = [ pkgs.python3Packages.pyflakes ]; }
"cd ${../picofactory/aoi/server} && pyflakes . && touch $out";
};
built-from =
pkgs.runCommand "built-from" {} ''echo "${src.rev}" > $out'';
in
jobs // {
gitHubStatus =
pkgs.releaseTools.aggregate {
name = "github-status-check";
constituents =
[ built-from ]
++ pkgs.lib.collect pkgs.lib.isDerivation jobs;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment