Compare commits
14 Commits
d49584c2c0
...
0cf14847ce
| Author | SHA1 | Date | |
|---|---|---|---|
| 0cf14847ce | |||
| 10fe8a0a1e | |||
| 86cd57f5f8 | |||
| ca114393cc | |||
| f864200c9b | |||
| 61acc41a18 | |||
| 02de87f9aa | |||
| 5b8c7a87a9 | |||
| 8d6ad63e5e | |||
|
48cdf8bf85
|
|||
|
7fb42ba49d
|
|||
|
19a2737148
|
|||
|
baf2def9cc
|
|||
|
242e042cb9
|
@@ -40,7 +40,7 @@ type (
|
|||||||
AllowOrphan bool
|
AllowOrphan bool
|
||||||
// Scheduling policy to set via sched_setscheduler(2). The zero value
|
// Scheduling policy to set via sched_setscheduler(2). The zero value
|
||||||
// skips this call. Supported policies are [SCHED_BATCH], [SCHED_IDLE].
|
// skips this call. Supported policies are [SCHED_BATCH], [SCHED_IDLE].
|
||||||
SchedPolicy int
|
SchedPolicy SchedPolicy
|
||||||
// Cgroup fd, nil to disable.
|
// Cgroup fd, nil to disable.
|
||||||
Cgroup *int
|
Cgroup *int
|
||||||
// ExtraFiles passed through to initial process in the container, with
|
// ExtraFiles passed through to initial process in the container, with
|
||||||
@@ -373,12 +373,23 @@ func (p *Container) Start() error {
|
|||||||
|
|
||||||
// sched_setscheduler: thread-directed but acts on all processes
|
// sched_setscheduler: thread-directed but acts on all processes
|
||||||
// created from the calling thread
|
// created from the calling thread
|
||||||
if p.SchedPolicy > 0 {
|
if p.SchedPolicy > 0 && p.SchedPolicy <= _SCHED_LAST {
|
||||||
|
var param schedParam
|
||||||
|
if priority, err := p.SchedPolicy.GetPriorityMin(); err != nil {
|
||||||
|
return &StartError{
|
||||||
|
Fatal: true,
|
||||||
|
Step: "get minimum priority",
|
||||||
|
Err: err,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
param.priority = priority
|
||||||
|
}
|
||||||
|
|
||||||
p.msg.Verbosef("setting scheduling policy %d", p.SchedPolicy)
|
p.msg.Verbosef("setting scheduling policy %d", p.SchedPolicy)
|
||||||
if err := schedSetscheduler(
|
if err := schedSetscheduler(
|
||||||
0, // calling thread
|
0, // calling thread
|
||||||
p.SchedPolicy,
|
p.SchedPolicy,
|
||||||
&schedParam{0},
|
¶m,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return &StartError{
|
return &StartError{
|
||||||
Fatal: true,
|
Fatal: true,
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
package container
|
package container
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding"
|
||||||
|
"strconv"
|
||||||
|
"sync"
|
||||||
. "syscall"
|
. "syscall"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
@@ -43,18 +46,132 @@ func Isatty(fd int) bool {
|
|||||||
return r == 0
|
return r == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SchedPolicy denotes a scheduling policy defined in include/uapi/linux/sched.h.
|
||||||
|
type SchedPolicy int
|
||||||
|
|
||||||
// include/uapi/linux/sched.h
|
// include/uapi/linux/sched.h
|
||||||
const (
|
const (
|
||||||
SCHED_NORMAL = iota
|
SCHED_NORMAL SchedPolicy = iota
|
||||||
SCHED_FIFO
|
SCHED_FIFO
|
||||||
SCHED_RR
|
SCHED_RR
|
||||||
SCHED_BATCH
|
SCHED_BATCH
|
||||||
_ // SCHED_ISO: reserved but not implemented yet
|
_SCHED_ISO // SCHED_ISO: reserved but not implemented yet
|
||||||
SCHED_IDLE
|
SCHED_IDLE
|
||||||
SCHED_DEADLINE
|
SCHED_DEADLINE
|
||||||
SCHED_EXT
|
SCHED_EXT
|
||||||
|
|
||||||
|
_SCHED_LAST SchedPolicy = iota - 1
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var _ encoding.TextMarshaler = _SCHED_LAST
|
||||||
|
var _ encoding.TextUnmarshaler = new(_SCHED_LAST)
|
||||||
|
|
||||||
|
// String returns a unique representation of policy, also used in encoding.
|
||||||
|
func (policy SchedPolicy) String() string {
|
||||||
|
switch policy {
|
||||||
|
case SCHED_NORMAL:
|
||||||
|
return ""
|
||||||
|
case SCHED_FIFO:
|
||||||
|
return "fifo"
|
||||||
|
case SCHED_RR:
|
||||||
|
return "rr"
|
||||||
|
case SCHED_BATCH:
|
||||||
|
return "batch"
|
||||||
|
case SCHED_IDLE:
|
||||||
|
return "idle"
|
||||||
|
case SCHED_DEADLINE:
|
||||||
|
return "deadline"
|
||||||
|
case SCHED_EXT:
|
||||||
|
return "ext"
|
||||||
|
|
||||||
|
default:
|
||||||
|
return "invalid policy " + strconv.Itoa(int(policy))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalText performs bounds checking and returns the result of String.
|
||||||
|
func (policy SchedPolicy) MarshalText() ([]byte, error) {
|
||||||
|
if policy == _SCHED_ISO || policy < 0 || policy > _SCHED_LAST {
|
||||||
|
return nil, EINVAL
|
||||||
|
}
|
||||||
|
return []byte(policy.String()), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// InvalidSchedPolicyError is an invalid string representation of a [SchedPolicy].
|
||||||
|
type InvalidSchedPolicyError string
|
||||||
|
|
||||||
|
func (InvalidSchedPolicyError) Unwrap() error { return EINVAL }
|
||||||
|
func (e InvalidSchedPolicyError) Error() string {
|
||||||
|
return "invalid scheduling policy " + strconv.Quote(string(e))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalText is the inverse of MarshalText.
|
||||||
|
func (policy *SchedPolicy) UnmarshalText(text []byte) error {
|
||||||
|
switch string(text) {
|
||||||
|
case "fifo":
|
||||||
|
*policy = SCHED_FIFO
|
||||||
|
case "rr":
|
||||||
|
*policy = SCHED_RR
|
||||||
|
case "batch":
|
||||||
|
*policy = SCHED_BATCH
|
||||||
|
case "idle":
|
||||||
|
*policy = SCHED_IDLE
|
||||||
|
case "deadline":
|
||||||
|
*policy = SCHED_DEADLINE
|
||||||
|
case "ext":
|
||||||
|
*policy = SCHED_EXT
|
||||||
|
|
||||||
|
case "":
|
||||||
|
*policy = 0
|
||||||
|
return nil
|
||||||
|
default:
|
||||||
|
return InvalidSchedPolicyError(text)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// for sched_get_priority_max and sched_get_priority_min
|
||||||
|
var (
|
||||||
|
schedPriority [_SCHED_LAST + 1][2]std.Int
|
||||||
|
schedPriorityErr [_SCHED_LAST + 1][2]error
|
||||||
|
schedPriorityOnce [_SCHED_LAST + 1][2]sync.Once
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetPriorityMax returns the maximum priority value that can be used with the
|
||||||
|
// scheduling algorithm identified by policy.
|
||||||
|
func (policy SchedPolicy) GetPriorityMax() (std.Int, error) {
|
||||||
|
schedPriorityOnce[policy][0].Do(func() {
|
||||||
|
priority, _, errno := Syscall(
|
||||||
|
SYS_SCHED_GET_PRIORITY_MAX,
|
||||||
|
uintptr(policy),
|
||||||
|
0, 0,
|
||||||
|
)
|
||||||
|
schedPriority[policy][0] = std.Int(priority)
|
||||||
|
if schedPriority[policy][0] < 0 {
|
||||||
|
schedPriorityErr[policy][0] = errno
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return schedPriority[policy][0], schedPriorityErr[policy][0]
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPriorityMin returns the minimum priority value that can be used with the
|
||||||
|
// scheduling algorithm identified by policy.
|
||||||
|
func (policy SchedPolicy) GetPriorityMin() (std.Int, error) {
|
||||||
|
schedPriorityOnce[policy][1].Do(func() {
|
||||||
|
priority, _, errno := Syscall(
|
||||||
|
SYS_SCHED_GET_PRIORITY_MIN,
|
||||||
|
uintptr(policy),
|
||||||
|
0, 0,
|
||||||
|
)
|
||||||
|
schedPriority[policy][1] = std.Int(priority)
|
||||||
|
if schedPriority[policy][1] < 0 {
|
||||||
|
schedPriorityErr[policy][1] = errno
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return schedPriority[policy][1], schedPriorityErr[policy][1]
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// schedParam is equivalent to struct sched_param from include/linux/sched.h.
|
// schedParam is equivalent to struct sched_param from include/linux/sched.h.
|
||||||
type schedParam struct {
|
type schedParam struct {
|
||||||
// sched_priority
|
// sched_priority
|
||||||
@@ -74,7 +191,7 @@ type schedParam struct {
|
|||||||
// this if you do not have something similar in place!
|
// this if you do not have something similar in place!
|
||||||
//
|
//
|
||||||
// [very subtle to use correctly]: https://www.openwall.com/lists/musl/2016/03/01/4
|
// [very subtle to use correctly]: https://www.openwall.com/lists/musl/2016/03/01/4
|
||||||
func schedSetscheduler(tid, policy int, param *schedParam) error {
|
func schedSetscheduler(tid int, policy SchedPolicy, param *schedParam) error {
|
||||||
if r, _, errno := Syscall(
|
if r, _, errno := Syscall(
|
||||||
SYS_SCHED_SETSCHEDULER,
|
SYS_SCHED_SETSCHEDULER,
|
||||||
uintptr(tid),
|
uintptr(tid),
|
||||||
|
|||||||
100
container/syscall_test.go
Normal file
100
container/syscall_test.go
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
package container_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
"math"
|
||||||
|
"reflect"
|
||||||
|
"syscall"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"hakurei.app/container"
|
||||||
|
"hakurei.app/container/std"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestSchedPolicyJSON(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
testCases := []struct {
|
||||||
|
policy container.SchedPolicy
|
||||||
|
want string
|
||||||
|
encodeErr error
|
||||||
|
decodeErr error
|
||||||
|
}{
|
||||||
|
{container.SCHED_NORMAL, `""`, nil, nil},
|
||||||
|
{container.SCHED_FIFO, `"fifo"`, nil, nil},
|
||||||
|
{container.SCHED_RR, `"rr"`, nil, nil},
|
||||||
|
{container.SCHED_BATCH, `"batch"`, nil, nil},
|
||||||
|
{4, `"invalid policy 4"`, syscall.EINVAL, container.InvalidSchedPolicyError("invalid policy 4")},
|
||||||
|
{container.SCHED_IDLE, `"idle"`, nil, nil},
|
||||||
|
{container.SCHED_DEADLINE, `"deadline"`, nil, nil},
|
||||||
|
{container.SCHED_EXT, `"ext"`, nil, nil},
|
||||||
|
{math.MaxInt, `"iso"`, syscall.EINVAL, container.InvalidSchedPolicyError("iso")},
|
||||||
|
}
|
||||||
|
for _, tc := range testCases {
|
||||||
|
name := tc.policy.String()
|
||||||
|
if tc.policy == container.SCHED_NORMAL {
|
||||||
|
name = "normal"
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Run(name, func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
got, err := json.Marshal(tc.policy)
|
||||||
|
if !errors.Is(err, tc.encodeErr) {
|
||||||
|
t.Fatalf("Marshal: error = %v, want %v", err, tc.encodeErr)
|
||||||
|
}
|
||||||
|
if err == nil && string(got) != tc.want {
|
||||||
|
t.Fatalf("Marshal: %s, want %s", string(got), tc.want)
|
||||||
|
}
|
||||||
|
|
||||||
|
var v container.SchedPolicy
|
||||||
|
if err = json.Unmarshal([]byte(tc.want), &v); !reflect.DeepEqual(err, tc.decodeErr) {
|
||||||
|
t.Fatalf("Unmarshal: error = %v, want %v", err, tc.decodeErr)
|
||||||
|
}
|
||||||
|
if err == nil && v != tc.policy {
|
||||||
|
t.Fatalf("Unmarshal: %d, want %d", v, tc.policy)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSchedPolicyMinMax(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
testCases := []struct {
|
||||||
|
policy container.SchedPolicy
|
||||||
|
min, max std.Int
|
||||||
|
err error
|
||||||
|
}{
|
||||||
|
{container.SCHED_NORMAL, 0, 0, nil},
|
||||||
|
{container.SCHED_FIFO, 1, 99, nil},
|
||||||
|
{container.SCHED_RR, 1, 99, nil},
|
||||||
|
{container.SCHED_BATCH, 0, 0, nil},
|
||||||
|
{4, -1, -1, syscall.EINVAL},
|
||||||
|
{container.SCHED_IDLE, 0, 0, nil},
|
||||||
|
{container.SCHED_DEADLINE, 0, 0, nil},
|
||||||
|
{container.SCHED_EXT, 0, 0, nil},
|
||||||
|
}
|
||||||
|
for _, tc := range testCases {
|
||||||
|
name := tc.policy.String()
|
||||||
|
if tc.policy == container.SCHED_NORMAL {
|
||||||
|
name = "normal"
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Run(name, func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
if priority, err := tc.policy.GetPriorityMax(); !reflect.DeepEqual(err, tc.err) {
|
||||||
|
t.Fatalf("GetPriorityMax: error = %v, want %v", err, tc.err)
|
||||||
|
} else if priority != tc.max {
|
||||||
|
t.Fatalf("GetPriorityMax: %d, want %d", priority, tc.max)
|
||||||
|
}
|
||||||
|
if priority, err := tc.policy.GetPriorityMin(); !reflect.DeepEqual(err, tc.err) {
|
||||||
|
t.Fatalf("GetPriorityMin: error = %v, want %v", err, tc.err)
|
||||||
|
} else if priority != tc.min {
|
||||||
|
t.Fatalf("GetPriorityMin: %d, want %d", priority, tc.min)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
12
flake.lock
generated
12
flake.lock
generated
@@ -7,11 +7,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1765384171,
|
"lastModified": 1772985280,
|
||||||
"narHash": "sha256-FuFtkJrW1Z7u+3lhzPRau69E0CNjADku1mLQQflUORo=",
|
"narHash": "sha256-FdrNykOoY9VStevU4zjSUdvsL9SzJTcXt4omdEDZDLk=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "home-manager",
|
"repo": "home-manager",
|
||||||
"rev": "44777152652bc9eacf8876976fa72cc77ca8b9d8",
|
"rev": "8f736f007139d7f70752657dff6a401a585d6cbc",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -23,11 +23,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1765311797,
|
"lastModified": 1772822230,
|
||||||
"narHash": "sha256-mSD5Ob7a+T2RNjvPvOA1dkJHGVrNVl8ZOrAwBjKBDQo=",
|
"narHash": "sha256-yf3iYLGbGVlIthlQIk5/4/EQDZNNEmuqKZkQssMljuw=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "09eb77e94fa25202af8f3e81ddc7353d9970ac1b",
|
"rev": "71caefce12ba78d84fe618cf61644dce01cf3a96",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|||||||
@@ -99,7 +99,7 @@
|
|||||||
hakurei = pkgs.pkgsStatic.callPackage ./package.nix {
|
hakurei = pkgs.pkgsStatic.callPackage ./package.nix {
|
||||||
inherit (pkgs)
|
inherit (pkgs)
|
||||||
# passthru.buildInputs
|
# passthru.buildInputs
|
||||||
go
|
go_1_26
|
||||||
clang
|
clang
|
||||||
|
|
||||||
# nativeBuildInputs
|
# nativeBuildInputs
|
||||||
@@ -182,7 +182,7 @@
|
|||||||
let
|
let
|
||||||
# this is used for interactive vm testing during development, where tests might be broken
|
# this is used for interactive vm testing during development, where tests might be broken
|
||||||
package = self.packages.${pkgs.stdenv.hostPlatform.system}.hakurei.override {
|
package = self.packages.${pkgs.stdenv.hostPlatform.system}.hakurei.override {
|
||||||
buildGoModule = previousArgs: pkgs.pkgsStatic.buildGoModule (previousArgs // { doCheck = false; });
|
buildGo126Module = previousArgs: pkgs.pkgsStatic.buildGo126Module (previousArgs // { doCheck = false; });
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|||||||
0
internal/azalea/azalea.bnf
Normal file
0
internal/azalea/azalea.bnf
Normal file
69
internal/azalea/azalea.go
Normal file
69
internal/azalea/azalea.go
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
//go:generate gocc -a azalea.bnf
|
||||||
|
package azalea
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
"io/fs"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"hakurei.app/container/check"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Parser struct {
|
||||||
|
Generator
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewParser(gen Generator) *Parser {
|
||||||
|
return &Parser{
|
||||||
|
Generator: gen,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func (p Parser) Initialise() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p Parser) Consume(ns string, file io.Reader) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ConsumeDir walks a directory and consumes all Azalea source files within it and all its subdirectories, as long as they end with the .az extension.
|
||||||
|
func (p Parser) ConsumeDir(dir *check.Absolute) error {
|
||||||
|
ds := dir.String()
|
||||||
|
return filepath.WalkDir(ds, func(path string, d fs.DirEntry, err error) (e error) {
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if d.IsDir() || !strings.HasSuffix(d.Name(), ".az") {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
rel, e := filepath.Rel(ds, path)
|
||||||
|
ns := strings.TrimSuffix(rel, ".az")
|
||||||
|
f, e := os.Open(path)
|
||||||
|
return p.Consume(ns, f)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// ConsumeAll consumes all provided readers as Azalea source code, each given the namespace `r%d` where `%d` is the index of the reader in the provided arguments.
|
||||||
|
func (p Parser) ConsumeAll(in ...io.Reader) error {
|
||||||
|
for i, r := range in {
|
||||||
|
err := p.Consume("r"+strconv.FormatInt(int64(i), 10), r)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ConsumeStrings consumes all provided strings as Azalea source code, each given the namespace `s%d` where `%d` is the index of the string in the provided arugments.
|
||||||
|
func (p Parser) ConsumeStrings(in ...string) error {
|
||||||
|
for i, s := range in {
|
||||||
|
err := p.Consume("s"+strconv.FormatInt(int64(i), 10), strings.NewReader(s))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
36
internal/azalea/generator.go
Normal file
36
internal/azalea/generator.go
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
package azalea
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Generator interface {
|
||||||
|
Finalise() (error, io.Writer)
|
||||||
|
}
|
||||||
|
|
||||||
|
type JsonGenerator struct {
|
||||||
|
t any
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewJsonGenerator[T any]() JsonGenerator {
|
||||||
|
t := new(T)
|
||||||
|
|
||||||
|
return JsonGenerator{
|
||||||
|
t,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (j *JsonGenerator) Finalise() (error, io.Writer) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
type PkgIRGenerator struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewPkgIRGenerator() PkgIRGenerator {
|
||||||
|
return PkgIRGenerator{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PkgIRGenerator) Finalise() (error, io.Writer) {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -40,7 +40,7 @@ type ExecPath struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SchedPolicy is the [container] scheduling policy.
|
// SchedPolicy is the [container] scheduling policy.
|
||||||
var SchedPolicy int
|
var SchedPolicy container.SchedPolicy
|
||||||
|
|
||||||
// PromoteLayers returns artifacts with identical-by-content layers promoted to
|
// PromoteLayers returns artifacts with identical-by-content layers promoted to
|
||||||
// the highest priority instance, as if mounted via [ExecPath].
|
// the highest priority instance, as if mounted via [ExecPath].
|
||||||
|
|||||||
@@ -82,6 +82,11 @@ install -Dm0500 \
|
|||||||
echo "Installing linux $1..."
|
echo "Installing linux $1..."
|
||||||
cp -av "$2" "$4"
|
cp -av "$2" "$4"
|
||||||
cp -av "$3" "$4"
|
cp -av "$3" "$4"
|
||||||
|
`))),
|
||||||
|
pkg.Path(AbsUsrSrc.Append(
|
||||||
|
".depmod",
|
||||||
|
), false, pkg.NewFile("depmod", []byte(`#!/bin/sh
|
||||||
|
exec /system/sbin/depmod -m /lib/modules "$@"
|
||||||
`))),
|
`))),
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -1210,6 +1215,11 @@ cgit 1.2.3-korg
|
|||||||
"all",
|
"all",
|
||||||
},
|
},
|
||||||
Install: `
|
Install: `
|
||||||
|
# kernel is not aware of kmod moduledir
|
||||||
|
install -Dm0500 \
|
||||||
|
/usr/src/.depmod \
|
||||||
|
/sbin/depmod
|
||||||
|
|
||||||
make \
|
make \
|
||||||
"-j$(nproc)" \
|
"-j$(nproc)" \
|
||||||
-f /usr/src/kernel/Makefile \
|
-f /usr/src/kernel/Makefile \
|
||||||
@@ -1217,9 +1227,10 @@ make \
|
|||||||
LLVM=1 \
|
LLVM=1 \
|
||||||
INSTALL_PATH=/work \
|
INSTALL_PATH=/work \
|
||||||
install \
|
install \
|
||||||
INSTALL_MOD_PATH=/work \
|
INSTALL_MOD_PATH=/work/system \
|
||||||
|
DEPMOD=/sbin/depmod \
|
||||||
modules_install
|
modules_install
|
||||||
rm -v /work/lib/modules/` + kernelVersion + `/build
|
rm -v /work/system/lib/modules/` + kernelVersion + `/build
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
Flex,
|
Flex,
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ func (t Toolchain) newKmod() (pkg.Artifact, string) {
|
|||||||
pkg.TarGzip,
|
pkg.TarGzip,
|
||||||
), nil, &MesonHelper{
|
), nil, &MesonHelper{
|
||||||
Setup: [][2]string{
|
Setup: [][2]string{
|
||||||
|
{"Dmoduledir", "/system/lib/modules"},
|
||||||
{"Dsysconfdir", "/system/etc"},
|
{"Dsysconfdir", "/system/etc"},
|
||||||
{"Dbashcompletiondir", "no"},
|
{"Dbashcompletiondir", "no"},
|
||||||
{"Dfishcompletiondir", "no"},
|
{"Dfishcompletiondir", "no"},
|
||||||
|
|||||||
@@ -125,6 +125,8 @@ func (t Toolchain) newLLVMVariant(variant string, attr *llvmAttr) pkg.Artifact {
|
|||||||
|
|
||||||
[2]string{"LLVM_INSTALL_BINUTILS_SYMLINKS", "ON"},
|
[2]string{"LLVM_INSTALL_BINUTILS_SYMLINKS", "ON"},
|
||||||
[2]string{"LLVM_INSTALL_CCTOOLS_SYMLINKS", "ON"},
|
[2]string{"LLVM_INSTALL_CCTOOLS_SYMLINKS", "ON"},
|
||||||
|
|
||||||
|
[2]string{"LLVM_LIT_ARGS", "'--verbose'"},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
34
package.nix
34
package.nix
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
stdenv,
|
stdenv,
|
||||||
buildGoModule,
|
buildGo126Module,
|
||||||
makeBinaryWrapper,
|
makeBinaryWrapper,
|
||||||
xdg-dbus-proxy,
|
xdg-dbus-proxy,
|
||||||
pkg-config,
|
pkg-config,
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
fuse3,
|
fuse3,
|
||||||
|
|
||||||
# for passthru.buildInputs
|
# for passthru.buildInputs
|
||||||
go,
|
go_1_26,
|
||||||
clang,
|
clang,
|
||||||
|
|
||||||
# for check
|
# for check
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
withStatic ? stdenv.hostPlatform.isStatic,
|
withStatic ? stdenv.hostPlatform.isStatic,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
buildGoModule rec {
|
buildGo126Module rec {
|
||||||
pname = "hakurei";
|
pname = "hakurei";
|
||||||
version = "0.3.6";
|
version = "0.3.6";
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ buildGoModule rec {
|
|||||||
];
|
];
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
go
|
go_1_26
|
||||||
pkg-config
|
pkg-config
|
||||||
wayland-scanner
|
wayland-scanner
|
||||||
];
|
];
|
||||||
@@ -125,16 +125,20 @@ buildGoModule rec {
|
|||||||
--inherit-argv0 --prefix PATH : ${lib.makeBinPath appPackages}
|
--inherit-argv0 --prefix PATH : ${lib.makeBinPath appPackages}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
passthru.targetPkgs = [
|
passthru = {
|
||||||
go
|
go = go_1_26;
|
||||||
clang
|
|
||||||
xorg.xorgproto
|
|
||||||
util-linux
|
|
||||||
|
|
||||||
# for go generate
|
targetPkgs = [
|
||||||
wayland-protocols
|
go_1_26
|
||||||
wayland-scanner
|
clang
|
||||||
]
|
xorg.xorgproto
|
||||||
++ buildInputs
|
util-linux
|
||||||
++ nativeBuildInputs;
|
|
||||||
|
# for go generate
|
||||||
|
wayland-protocols
|
||||||
|
wayland-scanner
|
||||||
|
]
|
||||||
|
++ buildInputs
|
||||||
|
++ nativeBuildInputs;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ testers.nixosTest {
|
|||||||
(writeShellScriptBin "hakurei-test" ''
|
(writeShellScriptBin "hakurei-test" ''
|
||||||
# Assert hst CGO_ENABLED=0: ${
|
# Assert hst CGO_ENABLED=0: ${
|
||||||
with pkgs;
|
with pkgs;
|
||||||
runCommand "hakurei-hst-cgo" { nativeBuildInputs = [ go ]; } ''
|
runCommand "hakurei-hst-cgo" { nativeBuildInputs = [ self.packages.${system}.hakurei.go ]; } ''
|
||||||
cp -r ${options.environment.hakurei.package.default.src} "$out"
|
cp -r ${options.environment.hakurei.package.default.src} "$out"
|
||||||
chmod -R +w "$out"
|
chmod -R +w "$out"
|
||||||
cp ${writeText "hst_cgo_test.go" ''package hakurei_test;import("testing";"hakurei.app/hst");func TestTemplate(t *testing.T){hst.Template()}''} "$out/hst_cgo_test.go"
|
cp ${writeText "hst_cgo_test.go" ''package hakurei_test;import("testing";"hakurei.app/hst");func TestTemplate(t *testing.T){hst.Template()}''} "$out/hst_cgo_test.go"
|
||||||
|
|||||||
Reference in New Issue
Block a user