-
Notifications
You must be signed in to change notification settings - Fork 24
Make ocm flake.nix ready #625
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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,127 @@ | ||
/* | ||
SPDX-FileCopyrightText: 2021 SAP SE or an SAP affiliate company and Gardener contributors | ||
|
||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
{ | ||
description = "Nix flake for ocm"; | ||
|
||
inputs = { | ||
# NixPkgs (nixos-23.11) | ||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; | ||
}; | ||
|
||
outputs = { self, nixpkgs, ... }: | ||
let | ||
pname = "ocm"; | ||
|
||
# System types to support. | ||
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; | ||
|
||
# Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'. | ||
forAllSystems = nixpkgs.lib.genAttrs supportedSystems; | ||
|
||
# Nixpkgs instantiated for supported system types. | ||
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; }); | ||
|
||
in | ||
{ | ||
# Provide some binary packages for selected system types. | ||
packages = forAllSystems (system: | ||
let | ||
pkgs = nixpkgsFor.${system}; | ||
inherit (pkgs) stdenv lib ; | ||
in | ||
{ | ||
${pname} = pkgs.buildGo121Module rec { | ||
inherit pname self; | ||
version = lib.fileContents ./VERSION; | ||
gitCommit = if (self ? rev) then self.rev else self.dirtyRev; | ||
state = if (self ? rev) then "clean" else "dirty"; | ||
|
||
# This vendorHash represents a dervative of all go.mod dependancies and needs to be adjusted with every change | ||
vendorHash = "sha256-CA3p9QNHo7mHCoXkuOojFAJen3TdieSsoQVivxPk3yw="; | ||
|
||
src = ./.; | ||
|
||
ldflags = [ | ||
"-s" "-w" | ||
"-X github.com/open-component-model/ocm/pkg/version.gitVersion=${version}" | ||
"-X github.com/open-component-model/ocm/pkg/version.gitTreeState=${state}" | ||
"-X github.com/open-component-model/ocm/pkg/version.gitCommit=${gitCommit}" | ||
# "-X github.com/open-component-model/ocm/pkg/version.buildDate=1970-01-01T0:00:00+0000" | ||
]; | ||
|
||
CGO_ENABLED = 0; | ||
|
||
subPackages = [ | ||
"cmds/ocm" | ||
"cmds/helminstaller" | ||
"cmds/demoplugin" | ||
"cmds/ecrplugin" | ||
]; | ||
|
||
nativeBuildInputs = [ pkgs.installShellFiles ]; | ||
|
||
postInstall = '' | ||
installShellCompletion --cmd ${pname} \ | ||
--zsh <($out/bin/${pname} completion zsh) \ | ||
--bash <($out/bin/${pname} completion bash) \ | ||
--fish <($out/bin/${pname} completion fish) | ||
''; | ||
|
||
meta = with lib; { | ||
description = "Open Component Model (OCM) is an open standard to describe software bills of delivery (SBOD)"; | ||
longDescription = '' | ||
OCM is a technology-agnostic and machine-readable format focused on the software artifacts that must be delivered for software products. | ||
The specification is also used to express metadata needed for security, compliance, and certification purpose. | ||
''; | ||
homepage = "https://ocm.software"; | ||
license = licenses.asl20; | ||
platforms = supportedSystems; | ||
}; | ||
}; | ||
}); | ||
|
||
# Add dependencies that are only needed for development | ||
devShells = forAllSystems (system: | ||
let | ||
pkgs = nixpkgsFor.${system}; | ||
in | ||
{ | ||
default = pkgs.mkShell { | ||
buildInputs = with pkgs; [ | ||
go_1_21 # golang 1.21 | ||
gopls # go language server | ||
gotools # go imports | ||
go-tools # static checks | ||
gnumake # standard make | ||
]; | ||
}; | ||
}); | ||
|
||
# The default package for 'nix build'. | ||
defaultPackage = forAllSystems (system: self.packages.${system}.${pname}); | ||
|
||
# These are the apps included in the default package. | ||
apps = forAllSystems (system: rec { | ||
${pname} = default; | ||
default = { | ||
type = "app"; | ||
program = self.packages.${system}.${pname} + "/bin/ocm"; | ||
}; | ||
helminstaller = { | ||
type = "app"; | ||
program = self.packages.${system}.${pname} + "/bin/helminstaller"; | ||
}; | ||
demo = { | ||
type = "app"; | ||
program = self.packages.${system}.${pname} + "/bin/demoplugin"; | ||
}; | ||
ecrplugin = { | ||
type = "app"; | ||
program = self.packages.${system}.${pname} + "/bin/ecrplugin"; | ||
}; | ||
}); | ||
}; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.